跳至内容 跳至搜索

Action Controller 缓存

缓存是一种廉价的方式,通过保存计算、渲染和数据库调用的结果来加速缓慢的应用程序。

您可以通过点击下面的模块来了解更多关于每种方法的信息。

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

config.action_controller.perform_caching = false

缓存存储

来自 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')
包含的模块