Class: Ruberto::FileCache

Inherits:
Object
  • Object
show all
Defined in:
lib/ruberto/configuration/file_cache.rb

Instance Method Summary collapse

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

#clearObject



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 }