Class 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
55:         def middleware
56:           @middleware ||= begin
57:             klass = Class.new
58:             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)
59:             klass
60:           end
61:         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
43:         def with_local_cache
44:           save_val = Thread.current[thread_local_key]
45:           begin
46:             Thread.current[thread_local_key] = LocalStore.new
47:             yield
48:           ensure
49:             Thread.current[thread_local_key] = save_val
50:           end
51:         end

Private Instance Methods

bypass_local_cache() click to toggle source
     # File lib/active_support/cache/strategy/local_cache.rb, line 152
152:           def bypass_local_cache
153:             save_cache = Thread.current[thread_local_key]
154:             begin
155:               Thread.current[thread_local_key] = nil
156:               yield
157:             ensure
158:               Thread.current[thread_local_key] = save_cache
159:             end
160:           end
local_cache() click to toggle source
     # File lib/active_support/cache/strategy/local_cache.rb, line 148
148:           def local_cache
149:             Thread.current[thread_local_key]
150:           end
thread_local_key() click to toggle source
     # File lib/active_support/cache/strategy/local_cache.rb, line 144
144:           def thread_local_key
145:             @thread_local_key ||= "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, '_').to_sym
146:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.