Class: Cachetastic::Adapters::LocalMemory
- Defined in:
- lib/cachetastic/adapters/local_memory.rb
Overview
An adapter to cache objects to memory. It is important to note that this cache is volatile. If the VM it is running in shuts down, everything in the cache gets vaporized.
See Cachetastic::Adapters::Base
for a list of public API methods.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#delete(key) ⇒ Object
set.
-
#expire_all ⇒ Object
delete.
-
#get(key) ⇒ Object
:nodoc:.
-
#initialize(klass) ⇒ LocalMemory
constructor
:nodoc:.
-
#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
:nodoc:
11 12 13 14 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 11 def initialize(klass) # :nodoc: super @_store = {} end |
Instance Method Details
#delete(key) ⇒ Object
set
26 27 28 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 26 def delete(key) # :nodoc: @_store.delete(key) end |
#expire_all ⇒ Object
delete
30 31 32 33 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 30 def expire_all # :nodoc: @_store = {} return nil end |
#get(key) ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 16 def get(key) # :nodoc: @_store[key] end |
#set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry) ⇒ Object
get
20 21 22 23 24 |
# File 'lib/cachetastic/adapters/local_memory.rb', line 20 def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry) # :nodoc: so = Cachetastic::Cache::StoreObject.new(key, value, expiry_time.from_now) @_store[key] = marshal(so) value end |