Class: Moneta::Proxy
Overview
Proxy base class
Direct Known Subclasses
Instance Attribute Summary collapse
- #adapter ⇒ Object readonly
Instance Method Summary collapse
-
#clear(options = {}) ⇒ void
Clear all keys in this store.
-
#close ⇒ Object
Close this store.
-
#delete(key, options = {}) ⇒ Object
Delete the key from the store and return the current value.
-
#increment(key, amount = 1, options = {}) ⇒ Object
Atomically increment integer value with key.
-
#initialize(adapter, options = {}) ⇒ Proxy
constructor
Constructor.
-
#key?(key, options = {}) ⇒ Boolean
Exists the value with key.
-
#load(key, options = {}) ⇒ Object
Fetch value with key.
-
#store(key, value, options = {}) ⇒ Object
Store value with key.
Methods inherited from Base
#[], #[]=, #decrement, #fetch
Methods included from Mixins::WithOptions
#expires, #prefix, #raw, #with
Constructor Details
#initialize(adapter, options = {}) ⇒ Proxy
Constructor
11 12 13 |
# File 'lib/moneta/proxy.rb', line 11 def initialize(adapter, = {}) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
5 6 7 |
# File 'lib/moneta/proxy.rb', line 5 def adapter @adapter end |
Instance Method Details
#clear(options = {}) ⇒ void
This method returns an undefined value.
Clear all keys in this store
75 76 77 78 |
# File 'lib/moneta/proxy.rb', line 75 def clear( = {}) @adapter.clear() self end |
#close ⇒ Object
Close this store
83 84 85 |
# File 'lib/moneta/proxy.rb', line 83 def close @adapter.close end |
#delete(key, options = {}) ⇒ Object
Delete the key from the store and return the current value
52 53 54 |
# File 'lib/moneta/proxy.rb', line 52 def delete(key, = {}) @adapter.delete(key, ) end |
#increment(key, amount = 1, options = {}) ⇒ Object
Atomically increment integer value with key
Not every Moneta store implements this method, a NotImplementedError if it is not supported.
66 67 68 |
# File 'lib/moneta/proxy.rb', line 66 def increment(key, amount = 1, = {}) @adapter.increment(key, amount, ) end |
#key?(key, options = {}) ⇒ Boolean
Exists the value with key
21 22 23 |
# File 'lib/moneta/proxy.rb', line 21 def key?(key, = {}) @adapter.key?(key, ) end |
#load(key, options = {}) ⇒ Object
Fetch value with key. Return nil if the key doesn’t exist
31 32 33 |
# File 'lib/moneta/proxy.rb', line 31 def load(key, = {}) @adapter.load(key, ) end |
#store(key, value, options = {}) ⇒ Object
Store value with key
42 43 44 |
# File 'lib/moneta/proxy.rb', line 42 def store(key, value, = {}) @adapter.store(key, value, ) end |