Class: Rack::MiniProfiler::FileStore::FileCache
- Inherits:
-
Object
- Object
- Rack::MiniProfiler::FileStore::FileCache
- Defined in:
- lib/mini_profiler/storage/file_store.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
-
#initialize(path, prefix) ⇒ FileCache
constructor
A new instance of FileCache.
Constructor Details
#initialize(path, prefix) ⇒ FileCache
Returns a new instance of FileCache.
6 7 8 9 |
# File 'lib/mini_profiler/storage/file_store.rb', line 6 def initialize(path, prefix) @path = path @prefix = prefix end |
Instance Method Details
#[](key) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/mini_profiler/storage/file_store.rb', line 11 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
20 21 22 |
# File 'lib/mini_profiler/storage/file_store.rb', line 20 def []=(key,val) ::File.open(path(key), "wb+") {|f| f.write Marshal.dump(val)} end |