Module: ActiveSupport::Cache::Strategy::LocalCache
- Defined in:
- lib/active_support/cache/strategy/local_cache.rb,
lib/active_support/cache/strategy/local_cache_middleware.rb
Overview
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.
Defined Under Namespace
Classes: LocalCacheRegistry, LocalStore, Middleware
Instance Method Summary collapse
-
#cleanup(options = nil) ⇒ Object
:nodoc:.
-
#clear(options = nil) ⇒ Object
:nodoc:.
-
#decrement(name, amount = 1, options = nil) ⇒ Object
:nodoc:.
-
#increment(name, amount = 1, options = nil) ⇒ Object
:nodoc:.
-
#middleware ⇒ Object
Middleware class can be inserted as a Rack handler to be local cache for the duration of request.
-
#with_local_cache ⇒ Object
Use a local cache for the duration of block.
Instance Method Details
#cleanup(options = nil) ⇒ Object
:nodoc:
81 82 83 84 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 81 def cleanup( = nil) # :nodoc: local_cache.clear() if local_cache super end |
#clear(options = nil) ⇒ Object
:nodoc:
76 77 78 79 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 76 def clear( = nil) # :nodoc: local_cache.clear() if local_cache super end |
#decrement(name, amount = 1, options = nil) ⇒ Object
:nodoc:
92 93 94 95 96 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 92 def decrement(name, amount = 1, = nil) # :nodoc: value = bypass_local_cache{super} increment_or_decrement(value, name, amount, ) value end |
#increment(name, amount = 1, options = nil) ⇒ Object
:nodoc:
86 87 88 89 90 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 86 def increment(name, amount = 1, = nil) # :nodoc: value = bypass_local_cache{super} increment_or_decrement(value, name, amount, ) value end |
#middleware ⇒ Object
Middleware class can be inserted as a Rack handler to be local cache for the duration of request.
70 71 72 73 74 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 70 def middleware @middleware ||= Middleware.new( "ActiveSupport::Cache::Strategy::LocalCache", local_cache_key) end |
#with_local_cache ⇒ Object
Use a local cache for the duration of block.
65 66 67 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 65 def with_local_cache use_temporary_local_cache(LocalStore.new) { yield } end |