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