Module: Moneta::IncrementSupport Private
- Included in:
- Adapters::ActiveRecord, Adapters::File, Adapters::HBase, Adapters::LRUHash, Adapters::MemcachedNative, Adapters::Memory, Adapters::PStore, Adapters::Sequel, Adapters::Sqlite
- Defined in:
- lib/moneta/mixins.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#increment(key, amount = 1, options = {}) ⇒ Object
Atomically increment integer value with key.
Instance Method Details
#increment(key, amount = 1, options = {}) ⇒ Object
Note:
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.
158 159 160 161 162 |
# File 'lib/moneta/mixins.rb', line 158 def increment(key, amount = 1, = {}) value = convert_for_increment(load(key, )) + amount store(key, value.to_s, ) value end |