Class: Rack::MiniProfiler::FileStore::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_profiler/storage/file_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, prefix) ⇒ FileCache

Returns a new instance of FileCache.



10
11
12
13
# File 'lib/mini_profiler/storage/file_store.rb', line 10

def initialize(path, prefix)
  @path = path
  @prefix = prefix
end

Instance Method Details

#[](key) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/mini_profiler/storage/file_store.rb', line 15

def [](key)
  begin
    data = ::File.open(path(key),"rb") {|f| f.read}
    return Marshal.load data
  rescue => e
    return nil
  end
end

#[]=(key, val) ⇒ Object



24
25
26
# File 'lib/mini_profiler/storage/file_store.rb', line 24

def []=(key,val)
  ::File.open(path(key), "wb+") {|f| f.write Marshal.dump(val)}
end