Class: AtomicCache::Storage::Dalli
- Extended by:
- Forwardable
- Defined in:
- lib/atomic_cache/storage/dalli.rb
Overview
A light wrapper over the Dalli client
Instance Method Summary collapse
- #add(key, new_value, ttl, user_options = {}) ⇒ Object
-
#initialize(dalli_client) ⇒ Dalli
constructor
A new instance of Dalli.
- #read(key, user_options = {}) ⇒ Object
- #set(key, value, user_options = {}) ⇒ Object
Methods inherited from Store
Constructor Details
#initialize(dalli_client) ⇒ Dalli
Returns a new instance of Dalli.
15 16 17 |
# File 'lib/atomic_cache/storage/dalli.rb', line 15 def initialize(dalli_client) @dalli_client = dalli_client end |
Instance Method Details
#add(key, new_value, ttl, user_options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/atomic_cache/storage/dalli.rb', line 19 def add(key, new_value, ttl, ={}) opts = .clone opts[:raw] = true # dalli expects time in seconds # https://github.com/petergoldstein/dalli/blob/b8f4afe165fb3e07294c36fb1c63901b0ed9ce10/lib/dalli/client.rb#L27 # TODO: verify this unit is being treated correctly through the system !!@dalli_client.add(key, new_value, ttl, opts) end |
#read(key, user_options = {}) ⇒ Object
29 30 31 |
# File 'lib/atomic_cache/storage/dalli.rb', line 29 def read(key, ={}) @dalli_client.get(key, ) end |
#set(key, value, user_options = {}) ⇒ Object
33 34 35 36 37 |
# File 'lib/atomic_cache/storage/dalli.rb', line 33 def set(key, value, ={}) ttl = [:ttl] .delete(:ttl) !!@dalli_client.set(key, value, ttl, ) end |