Class: Moneta::Adapters::LMC

Inherits:
Object
  • Object
show all
Includes:
Defaults
Defined in:
lib/moneta/adapters/lmc.rb

Instance Method Summary collapse

Methods included from Defaults

#[]=, #fetch

Constructor Details

#initialize(options = {}) ⇒ LMC

Returns a new instance of LMC.



13
14
15
# File 'lib/moneta/adapters/lmc.rb', line 13

def initialize(options = {})
  @hash = LocalMemCache.new(:filename => options[:filename])
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/moneta/adapters/lmc.rb', line 17

def [](key)
  deserialize(@hash[key_for(key)])
end

#clearObject



25
26
27
# File 'lib/moneta/adapters/lmc.rb', line 25

def clear(*)
  @hash.clear
end

#delete(key) ⇒ Object



33
34
35
36
37
# File 'lib/moneta/adapters/lmc.rb', line 33

def delete(key, *)
  value = self[key]
  @hash.delete(key_for(key))
  value
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/moneta/adapters/lmc.rb', line 29

def key?(key, *)
  @hash.keys.include?(key_for(key))
end

#store(key, value) ⇒ Object



21
22
23
# File 'lib/moneta/adapters/lmc.rb', line 21

def store(key, value, *) 
  @hash[key_for(key)] = serialize(value)
end