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, options = nil)
  options = merged_options(options)
  key = normalize_key(name, options)

  instrument(:decrement, key, amount: amount) do
    modify_value(name, -amount, options)
  end
end