跳至内容 跳至搜索

Action Controller Caching

Caching 是一种廉价的方法,可以通过保留计算、渲染和数据库调用的结果以供后续请求使用,从而加快慢速应用程序的速度。

注意:要关闭 Action Controller 提供的所有缓存,请设置

config.action_controller.perform_caching = false

Caching 存储

来自 ActiveSupport::Cache 的所有缓存存储都可以用作 Action Controller 缓存的后端。

配置示例(FileStore 是默认值)

config.action_controller.cache_store = :memory_store
config.action_controller.cache_store = :file_store, '/path/to/cache/directory'
config.action_controller.cache_store = :mem_cache_store, 'localhost'
config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new('localhost:11211')
config.action_controller.cache_store = MyOwnStore.new('parameter')
包含的模块