Class: Sprockets::Cache::FileStore
- Inherits:
-
Object
- Object
- Sprockets::Cache::FileStore
- Defined in:
- lib/sprockets/cache/file_store.rb
Overview
Instance Method Summary collapse
-
#[](key) ⇒ Object
Lookup value in cache.
-
#[]=(key, value) ⇒ Object
Save value to cache.
-
#initialize(root) ⇒ FileStore
constructor
A new instance of FileStore.
Constructor Details
Instance Method Details
#[](key) ⇒ Object
Lookup value in cache
20 21 22 23 |
# File 'lib/sprockets/cache/file_store.rb', line 20 def [](key) pathname = path_for(key) pathname.exist? ? pathname.open('rb') { |f| Marshal.load(f) } : nil end |
#[]=(key, value) ⇒ Object
Save value to cache
26 27 28 29 |
# File 'lib/sprockets/cache/file_store.rb', line 26 def []=(key, value) path_for(key).open('w') { |f| Marshal.dump(value, f)} value end |