instance method write_counter

Ruby on Rails 8.1.2

Since v8.1.2

Signature

write_counter(name, value, **options)

Writes a counter that can then be modified by #increment / #decrement.

cache.write_counter("foo", 1)
cache.read_counter("foo") # => 1
cache.increment("foo")
cache.read_counter("foo") # => 2

Options are passed to the underlying cache implementation.

Parameters

name req
value req
options keyrest
Source
# File activesupport/lib/active_support/cache.rb, line 775
      def write_counter(name, value, **options)
        options = merged_options(options).merge(raw: true)
        write(name, value.to_i, **options)
      end

Defined in activesupport/lib/active_support/cache.rb line 775 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Cache::Store

Type at least 2 characters to search.

↑↓ navigate · open · esc close