开发者

Expire option doesn't work in Rails.cache

开发者 https://www.devze.com 2023-01-27 17:55 出处:网络
I use the Rails.cache.fetch method with the :expires_in option i开发者_运维技巧n Rails 2.3.10.

I use the Rails.cache.fetch method with the :expires_in option i开发者_运维技巧n Rails 2.3.10.

Rails.cache.fetch "key", :expires_in => 2.seconds

In development, my cache never get expired and Rails always hits the cache.

Log: "Cache hit"


The default cache in Rails 2 is ActiveSupport::Cache::MemoryStore. It does not support expiration with the :expires_in option. In fact, only ActiveSupport::Cache::MemCacheStore has support for cache expiration.

In Rails 3, :expires_in is supported for all cache stores.

0

精彩评论

暂无评论...
验证码 换一张
取 消