class ActiveSupport::Cache::Store

def initialize(options = nil)

relevant cache operations, such as #read, #write, and #fetch.
Any other specified options are treated as default options for the

+ArgumentError+.
+:compressor+ options. Specifying them together will raise an
The +:coder+ option is mutally exclusive with the +:serializer+ and

mutation.
coder: nil to avoid the overhead of safeguarding against
guarantee that cache values will not be mutated, you can specify
example, if you are using ActiveSupport::Cache::MemoryStore and can
coder: nil to omit the serializer, compressor, and coder. For
If the store can handle cache entries directly, you may also specify

+:compressor+ options instead.
serializer or compressor, you should specify the +:serializer+ or
some performance optimizations. If you only need to override the
The default coder composes the serializer and compressor, and includes

Must respond to +dump+ and +load+.
The coder for serializing and (optionally) compressing cache entries.
[+:coder+]

ActiveSupport::Cache.lookup_store(:redis_cache_store, compressor: MyCompressor)

end
end
end
# decompression logic...
else
Zlib.inflate(compressed)
if compressed.start_with?("\x78")
def self.inflate(compressed)

end
# compression logic... (make sure result does not start with "\x78"!)
def self.deflate(dumped)
module MyCompressor

values for Zlib's "\x78" signature:
that also decompresses old cache entries, you can check compressed
The default compressor is +Zlib+. To define a new custom compressor

and +inflate+.
The compressor for serialized cache values. Must respond to +deflate+
[+:compressor+]

but it requires the +msgpack+ gem.
serializer. The +:message_pack+ serializer may improve performance,
mechanism, allowing easy migration from (or to) the default
+:message_pack+ serializer includes the same deserialization fallback
preconfigured serializer based on ActiveSupport::MessagePack. The
You can also specify serializer: :message_pack to use a

the entire cache.
makes it easy to migrate between format versions without invalidating
mechanism to deserialize values from any format version. This behavior
default serializer for each format version includes a fallback
+config.active_support.cache_format_version+ when using Rails). The
The default serializer depends on the cache format version (set via

The serializer for cached values. Must respond to +dump+ and +load+.
[+:serializer+]

your application shares a cache with other applications.
Sets the namespace for the cache. This option is especially useful if
[+:namespace+]

==== Options

Creates a new cache.
def initialize(options = nil)
  @options = options ? validate_options(normalize_options(options)) : {}
  @options[:compress] = true unless @options.key?(:compress)
  @options[:compress_threshold] ||= DEFAULT_COMPRESS_LIMIT
  @coder = @options.delete(:coder) do
    legacy_serializer = Cache.format_version < 7.1 && !@options[:serializer]
    serializer = @options.delete(:serializer) || default_serializer
    serializer = Cache::SerializerWithFallback[serializer] if serializer.is_a?(Symbol)
    compressor = @options.delete(:compressor) { Zlib }
    Cache::Coder.new(serializer, compressor, legacy_serializer: legacy_serializer)
  end
  @coder ||= Cache::SerializerWithFallback[:passthrough]
  @coder_supports_compression = @coder.respond_to?(:dump_compressed)
end