Local Cache Strategy¶ ↑
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
Methods
- L
-
- M
-
- N
-
- U
-
- W
-
Class Public methods
new(...)
Link
Source:
show
|
on GitHub
def initialize(...)
super
@local_cache_key = "#{self.class.name.underscore}_local_cache_#{object_id}".gsub(/[\/-]/, "_").to_sym
end
Instance Public methods
local_cache()
Link
Source:
show
|
on GitHub
def local_cache
LocalCacheRegistry.cache_for(local_cache_key)
end
middleware()
Link
Middleware class can be inserted as a Rack handler to be local cache for the duration of request.
Source:
show
|
on GitHub
def middleware
@middleware ||= Middleware.new("ActiveSupport::Cache::Strategy::LocalCache", self)
end
new_local_cache()
Link
Source:
show
|
on GitHub
def new_local_cache
LocalCacheRegistry.set_cache_for(local_cache_key, LocalStore.new)
end
unset_local_cache()
Link
Unset the current local cache.
Source:
show
|
on GitHub
def unset_local_cache
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
end
with_local_cache(&block)
Link
Use a local cache for the duration of block.
Source:
show
|
on GitHub
def with_local_cache(&block)
use_temporary_local_cache(LocalStore.new, &block)
end