Module: DalliStorePatch
- Defined in:
- lib/dalli_store_patch.rb
Overview
monky patch support cas interface for ActiveSupport::Cache::DalliStore
Instance Method Summary collapse
- #read_cas(name, options = {}) ⇒ Object
- #touch(key, ttl = nil) ⇒ Object
- #write_cas(name, value, options = {}) ⇒ Object
Instance Method Details
#read_cas(name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dalli_store_patch.rb', line 9 def read_cas(name, = {}) name = namespaced_key(name, ) instrument(:get_cas, name) do |_payload| with { |c| c.get_cas(name) } end rescue Dalli::DalliError => e logger.error("DalliError: #{e.}") if logger raise if raise_errors? false end |
#touch(key, ttl = nil) ⇒ Object
4 5 6 7 |
# File 'lib/dalli_store_patch.rb', line 4 def touch(key, ttl = nil) ttl ||= [:expires_in].to_i @data.touch key, ttl end |
#write_cas(name, value, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dalli_store_patch.rb', line 21 def write_cas(name, value, = {}) name = namespaced_key(name, ) expires_in = [:expires_in] instrument(:set_cas, name, value) do |_payload| cas = .delete(:cas) || 0 expires_in = .delete(:expires_in) with { |c| c.set_cas(name, value, cas, expires_in, ) } end rescue Dalli::DalliError => e logger.error("DalliError: #{e.}") if logger raise if raise_errors? false end |