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
Explicitly close the 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
A new instance of Proxy.
-
#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 included from Defaults
#[], #[]=, #decrement, #fetch
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(adapter, options = {}) ⇒ Proxy
Returns a new instance of Proxy.
11 12 13 |
# File 'lib/moneta/proxy.rb', line 11 def initialize(adapter, = {}) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
7 8 9 |
# File 'lib/moneta/proxy.rb', line 7 def adapter @adapter end |
Instance Method Details
#clear(options = {}) ⇒ void
This method returns an undefined value.
Clear all keys in this store
77 78 79 80 |
# File 'lib/moneta/proxy.rb', line 77 def clear( = {}) adapter.clear() self end |
#close ⇒ Object
Explicitly close the store
26 27 28 |
# File 'lib/moneta/proxy.rb', line 26 def close adapter.close end |
#delete(key, options = {}) ⇒ Object
Delete the key from the store and return the current value
68 69 70 |
# File 'lib/moneta/proxy.rb', line 68 def delete(key, = {}) adapter.delete(key, ) end |
#increment(key, amount = 1, options = {}) ⇒ Object
Not every Moneta store implements this method, a NotImplementedError is raised if it is not supported.
Atomically increment integer value with key
This method also accepts negative amounts.
21 22 23 |
# File 'lib/moneta/proxy.rb', line 21 def increment(key, amount = 1, = {}) adapter.increment(key, amount, ) end |
#key?(key, options = {}) ⇒ Boolean
Exists the value with key
16 17 18 |
# File 'lib/moneta/proxy.rb', line 16 def key?(key, = {}) adapter.key?(key, ) end |
#load(key, options = {}) ⇒ Object
Fetch value with key. Return nil if the key doesn’t exist
40 41 42 |
# File 'lib/moneta/proxy.rb', line 40 def load(key, = {}) adapter.load(key, ) end |
#store(key, value, options = {}) ⇒ Object
Store value with key
55 56 57 |
# File 'lib/moneta/proxy.rb', line 55 def store(key, value, = {}) adapter.store(key, value, ) end |