Class: ActiveSupport::Cache::MemcacheStore

Inherits:
Object
  • Object
show all
Defined in:
lib/circuitbox/memcache_store.rb

Instance Method Summary collapse

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, options = {})
  @cache.get(key, options)
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, options = {})
  if expires_in = options.delete(:expires_in)
    options[:expiry] = expires_in.to_i
  end

  @cache.set(key, value, options)
end