class ActiveSupport::Cache::Store
def write(name, value, options = nil)
used to support recyclable cache keys.
version, the read will be treated as a cache miss. This feature is
from the cache, if the cached version does not match the requested
* +:version+ - Specifies a version for the cache entry. When reading
cache.write(key, value, expires_at: Time.now.at_end_of_hour)
cache = ActiveSupport::Cache::MemoryStore.new
* +:expires_at+ - Sets an absolute expiration time for the cache entry.
cache.write(key, value, expires_in: 1.minute) # Set a lower value for one entry
cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 5.minutes)
+:expires_in+.
specified in seconds. +:expire_in+ and +:expired_in+ are aliases for
* +:expires_in+ - Sets a relative expiration time for the cache entry,
to +1.kilobyte+.
\Cache entries larger than this threshold will be compressed. Defaults
* +:compress_threshold+ - The compression threshold, specified in bytes.
* compress: false - Disables compression of the cache entry.
==== Options
fewer cache evictions and higher hit rates.
allows more data to be stored in the same memory footprint, leading to
By default, cache entries larger than 1kB are compressed. Compression
by the +coder+'s +dump+ and +load+ methods.
Writes the value to the cache with the key. The value must be supported
def write(name, value, options = nil) options = merged_options(options) instrument(:write, name, options) do entry = Entry.new(value, **options.merge(version: normalize_version(name, options))) write_entry(normalize_key(name, options), entry, **options) end end