ruby-on-rails – 有没有办法让一个Rails 3.x应用程序使用两个不
在Rails 3.1中,我可以在config / environments / *.yml中指定缓存机制.现在,将其设置为:file_store是缓存Dragonfly图像的好方法,但当然其他所有内容也将缓存为文件(操作,片段等).
现在,有没有办法让一个应用程序使用两个不同的缓存存储 – 例如,Dragonfly所做的一切都存储在:file_store中,而其他一切都存储在Memcache中? 解决方法
总之,是的.
Rack :: Cache separates cache entries into MetaStore和EntityStore.
以下是通过dalli gem建议的memcached配置. config.cache_store = :dalli_store config.action_dispatch.rack_cache = { :metastore => Dalli::Client.new,:entitystore => URI.encode("file:#{Rails.root}/tmp/cache/rack/body"),:allow_reload => false } 另一个内存存储是Redis,您可以使用@jodosha的redis-store进行配置. 根据您的问题的标题,人们可能会到达这里寻找一种方法,以最低延迟的顺序链接多个缓存层. 此功能由@jch的cascade-store提供,这是另一个custom rails cache store.Rails示例: config.cache_store = [:cascade_store,:stores => [ [:memory_store,:size => 5.megabytes,:expires_in => 15.minutes],[:mem_cache_store,'localhost:11211'],]] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |