Class: APICache::DalliStore
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- APICache::DalliStore
- Defined in:
- lib/api_cache/dalli_store.rb
Instance Method Summary collapse
- #created_at(key) ⇒ Object
-
#delete(key) ⇒ Object
Delete value.
-
#exists?(key) ⇒ Boolean
Does a given key exist in the cache?.
-
#get(key) ⇒ Object
Get value.
-
#initialize(store) ⇒ DalliStore
constructor
A new instance of DalliStore.
-
#set(key, value) ⇒ Object
Set value.
Methods inherited from AbstractStore
Constructor Details
#initialize(store) ⇒ DalliStore
Returns a new instance of DalliStore.
3 4 5 |
# File 'lib/api_cache/dalli_store.rb', line 3 def initialize(store) @dalli = store end |
Instance Method Details
#created_at(key) ⇒ Object
29 30 31 |
# File 'lib/api_cache/dalli_store.rb', line 29 def created_at(key) @dalli.get("#{key}_created_at") end |
#delete(key) ⇒ Object
Delete value.
20 21 22 |
# File 'lib/api_cache/dalli_store.rb', line 20 def delete(key) @dalli.delete(key) end |
#exists?(key) ⇒ Boolean
Does a given key exist in the cache?
25 26 27 |
# File 'lib/api_cache/dalli_store.rb', line 25 def exists?(key) !get(key).nil? end |
#get(key) ⇒ Object
Get value.
15 16 17 |
# File 'lib/api_cache/dalli_store.rb', line 15 def get(key) @dalli.get(key) end |
#set(key, value) ⇒ Object
Set value. Returns true if success.
8 9 10 11 12 |
# File 'lib/api_cache/dalli_store.rb', line 8 def set(key, value) @dalli.set(key, value) @dalli.set("#{key}_created_at", Time.now) true end |