Method: ActiveSupport::Cache::FileStore#decrement
- Defined in:
- activesupport/lib/active_support/cache/file_store.rb
#decrement(name, amount = 1, options = nil) ⇒ Object
Decrement a cached integer value. Returns the updated value.
If the key is unset, it will be set to -amount.
cache.decrement("foo") # => -1
To set a specific value, call #write:
cache.write("baz", 5)
cache.decrement("baz") # => 4
80 81 82 83 84 85 86 87 |
# File 'activesupport/lib/active_support/cache/file_store.rb', line 80 def decrement(name, amount = 1, = nil) = () key = normalize_key(name, ) instrument(:decrement, key, amount: amount) do modify_value(name, -amount, ) end end |