Class: ActiveSupport::Cache::SpymemcachedStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::SpymemcachedStore
- Defined in:
- lib/active_support/cache/spymemcached_store.rb
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
Instance Method Summary collapse
- #clear ⇒ Object
- #decrement(key, amount = 1) ⇒ Object
- #delete(key, options = nil) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
- #exist?(key, options = nil) ⇒ Boolean
- #increment(key, amount = 1) ⇒ Object
-
#initialize(*addresses) ⇒ SpymemcachedStore
constructor
A new instance of SpymemcachedStore.
- #read(key, options = nil) ⇒ Object
-
#write(key, value, options = nil) ⇒ Object
Set the key to the given value.
Constructor Details
#initialize(*addresses) ⇒ SpymemcachedStore
Returns a new instance of SpymemcachedStore.
9 10 11 12 13 14 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 9 def initialize(*addresses) addresses.flatten! @addresses = addresses @cache = Spymemcached.new(@addresses) end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
7 8 9 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 7 def addresses @addresses end |
Instance Method Details
#clear ⇒ Object
53 54 55 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 53 def clear @cache.flush end |
#decrement(key, amount = 1) ⇒ Object
43 44 45 46 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 43 def decrement(key, amount=1) log 'decrementing', key, amount @cache.decr(key, amount) end |
#delete(key, options = nil) ⇒ Object
29 30 31 32 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 29 def delete(key, = nil) super @cache.del(key) end |
#delete_matched(matcher, options = nil) ⇒ Object
48 49 50 51 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 48 def delete_matched(matcher, = nil) super raise NotImplementedError end |
#exist?(key, options = nil) ⇒ Boolean
34 35 36 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 34 def exist?(key, = nil) !read(key, ).nil? end |
#increment(key, amount = 1) ⇒ Object
38 39 40 41 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 38 def increment(key, amount=1) log 'incrementing', key, amount @cache.incr(key, amount) end |
#read(key, options = nil) ⇒ Object
16 17 18 19 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 16 def read(key, = nil) super @cache.get(key, ( && [:raw])) end |
#write(key, value, options = nil) ⇒ Object
Set the key to the given value. Pass :unless_exist => true if you want to skip setting a key that already exists.
23 24 25 26 27 |
# File 'lib/active_support/cache/spymemcached_store.rb', line 23 def write(key, value, = nil) super method = unless_exist?() ? :add : :set @cache.send(method, key, value, expiry().to_i, ( && [:raw])) end |