Class/Module Index [+]

Quicksearch

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() click to toggle source

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

# File lib/active_support/cache/strategy/local_cache.rb, line 55
def middleware
  @middleware ||= begin
    klass = Class.new
    klass.class_eval(              class << self                def name                  "ActiveSupport::Cache::Strategy::LocalCache"                end                alias :to_s :name              end              def initialize(app)                @app = app              end              def call(env)                Thread.current[:#{thread_local_key}] = LocalStore.new                @app.call(env)              ensure                Thread.current[:#{thread_local_key}] = nil              end, __FILE__, __LINE__ + 1)
    klass
  end
end
with_local_cache() click to toggle source

Use a local cache for the duration of block.

# File lib/active_support/cache/strategy/local_cache.rb, line 43
def with_local_cache
  save_val = Thread.current[thread_local_key]
  begin
    Thread.current[thread_local_key] = LocalStore.new
    yield
  ensure
    Thread.current[thread_local_key] = save_val
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.