Class: ActiveSupport::Cache::MemcacheStore
- Inherits:
-
Object
- Object
- ActiveSupport::Cache::MemcacheStore
- Defined in:
- lib/circuitbox/memcache_store.rb
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #increment(key) ⇒ Object
-
#initialize(cache) ⇒ MemcacheStore
constructor
A new instance of MemcacheStore.
- #read(key, options = {}) ⇒ Object
- #write(key, value, options = {}) ⇒ Object
Constructor Details
#initialize(cache) ⇒ MemcacheStore
Returns a new instance of MemcacheStore.
4 5 6 |
# File 'lib/circuitbox/memcache_store.rb', line 4 def initialize(cache) @cache = cache end |
Instance Method Details
#delete(key) ⇒ Object
26 27 28 |
# File 'lib/circuitbox/memcache_store.rb', line 26 def delete(key) @cache.delete(key) end |
#increment(key) ⇒ Object
14 15 16 |
# File 'lib/circuitbox/memcache_store.rb', line 14 def increment(key) @cache.incr(key) end |
#read(key, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/circuitbox/memcache_store.rb', line 8 def read(key, = {}) @cache.get(key, ) rescue Memcached::NotFound nil end |
#write(key, value, options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/circuitbox/memcache_store.rb', line 18 def write(key, value, = {}) if expires_in = .delete(:expires_in) [:expiry] = expires_in.to_i end @cache.set(key, value, ) end |