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.

Namespace

Class

Methods

Instance Public methods

middleware()

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

📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 89
        def middleware
          @middleware ||= Middleware.new(
            "ActiveSupport::Cache::Strategy::LocalCache",
            local_cache_key)
        end
🔎 See on GitHub

with_local_cache()

Use a local cache for the duration of block.

📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 83
        def with_local_cache
          use_temporary_local_cache(LocalStore.new) { yield }
        end
🔎 See on GitHub