Class: Makara::Cache::MemoryStore
- Inherits:
-
Object
- Object
- Makara::Cache::MemoryStore
- Defined in:
- lib/makara/cache/memory_store.rb
Instance Method Summary collapse
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
- #read(key) ⇒ Object
- #write(key, value, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
5 6 7 |
# File 'lib/makara/cache/memory_store.rb', line 5 def initialize @data = {} end |
Instance Method Details
#read(key) ⇒ Object
9 10 11 12 |
# File 'lib/makara/cache/memory_store.rb', line 9 def read(key) clean @data[key].try(:[], 0) end |
#write(key, value, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/makara/cache/memory_store.rb', line 14 def write(key, value, = {}) clean @data[key] = [value, Time.now.to_i + ([:expires_in] || 5).to_i] true end |