Class: Ruberto::FileCache
- Inherits:
-
Object
- Object
- Ruberto::FileCache
- Defined in:
- lib/ruberto/configuration/file_cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(file_cache_path) ⇒ FileCache
constructor
A new instance of FileCache.
- #read(key) ⇒ Object
- #write(key, value) ⇒ Object
Constructor Details
#initialize(file_cache_path) ⇒ FileCache
Returns a new instance of FileCache.
7 8 9 10 11 |
# File 'lib/ruberto/configuration/file_cache.rb', line 7 def initialize(file_cache_path) @file_cache_path = file_cache_path @store = PStore.new(file_cache_path) reset_if_incompatible! end |
Instance Method Details
#clear ⇒ Object
16 17 18 |
# File 'lib/ruberto/configuration/file_cache.rb', line 16 def clear File.delete(@file_cache_path) if File.exist?(@file_cache_path) end |
#delete(key) ⇒ Object
20 |
# File 'lib/ruberto/configuration/file_cache.rb', line 20 def delete(key) = @store.transaction { @store.delete(key) } |
#read(key) ⇒ Object
13 |
# File 'lib/ruberto/configuration/file_cache.rb', line 13 def read(key) = @store.transaction { @store[key] } |
#write(key, value) ⇒ Object
14 |
# File 'lib/ruberto/configuration/file_cache.rb', line 14 def write(key, value) = @store.transaction { @store[key] = value } |