开发者

Expire option doesn't work in Rails.cache

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜