本地缓存策略¶ ↑
实现 LocalCache 的缓存会在一个块的持续时间内使用内存缓存作为后备。对于同一键的缓存的重复调用将命中内存缓存以获得更快的访问。
命名空间
方法
- L
-
- M
-
- N
-
- U
-
- W
-
实例公共方法
local_cache() Link
Source: show | on GitHub
def local_cache
LocalCacheRegistry.cache_for(local_cache_key)
end
middleware() Link
中间件类可以作为 Rack 处理程序插入,以便在请求期间进行本地缓存。
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
Source: show | on GitHub
def unset_local_cache
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
end
with_local_cache(&block) Link
Source: show | on GitHub
def with_local_cache(&block)
use_temporary_local_cache(LocalStore.new, &block)
end