class method
self.new
Ruby on Rails 7.0.10
Since v3.0.20Signature
self.new(options = nil)
Creates a new cache.
Options
-
:namespace- Sets the namespace for the cache. This option is especially useful if your application shares a cache with other applications. -
:coder- Replaces the default cache entry serialization mechanism with a custom one. Thecodermust respond todumpandload. Using a custom coder disables automatic compression.
Any other specified options are treated as default options for the relevant cache operations, such as #read, #write, and #fetch.
Parameters
-
optionsopt = nil
Source
# File activesupport/lib/active_support/cache.rb, line 211
def initialize(options = nil)
@options = options ? normalize_options(options) : {}
@options[:compress] = true unless @options.key?(:compress)
@options[:compress_threshold] = DEFAULT_COMPRESS_LIMIT unless @options.key?(:compress_threshold)
@coder = @options.delete(:coder) { default_coder } || NullCoder
@coder_supports_compression = @coder.respond_to?(:dump_compressed)
end
Defined in activesupport/lib/active_support/cache.rb line 211
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store