Class: Cachetastic::Adapters::LocalMemory
- Defined in:
- lib/cachetastic/adapters/local_memory.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#delete(key) ⇒ Object
set.
-
#expire_all ⇒ Object
delete.
- #get(key, &block) ⇒ Object
-
#initialize(klass) ⇒ LocalMemory
constructor
A new instance of LocalMemory.
-
#set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry) ⇒ Object
get.
Methods inherited from Base
#debug?, #marshal, #transform_key, #unmarshal, #valid?
Constructor Details
#initialize(klass) ⇒ LocalMemory
Returns a new instance of LocalMemory.
5 6 7 8 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 5 def initialize(klass) super @_store = {} end |
Instance Method Details
#delete(key) ⇒ Object
set
20 21 22 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 20 def delete(key) @_store.delete(key) end |
#expire_all ⇒ Object
delete
24 25 26 27 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 24 def expire_all @_store = {} return nil end |
#get(key, &block) ⇒ Object
10 11 12 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 10 def get(key, &block) @_store[key] end |
#set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry) ⇒ Object
get
14 15 16 17 18 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 14 def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry) so = Cachetastic::Cache::StoreObject.new(key, value, expiry_time.from_now) @_store[key] = marshal(so) value end |