W3cubDocs

/Ruby on Rails 7.0

module ActiveSupport::Cache::Strategy::LocalCache

Caches that implement LocalCache will be backed by an in-memory cache for the duration of a block. Repeated calls to the cache for the same key will hit the in-memory cache for faster access.

Public Instance Methods

middleware() Show source
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 69
def middleware
  @middleware ||= Middleware.new(
    "ActiveSupport::Cache::Strategy::LocalCache",
    local_cache_key)
end

Middleware class can be inserted as a Rack handler to be local cache for the duration of request.

with_local_cache(&block) Show source
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 63
def with_local_cache(&block)
  use_temporary_local_cache(LocalStore.new, &block)
end

Use a local cache for the duration of block.

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.