Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expire option doesn't work in Rails.cache

I use the Rails.cache.fetch method with the :expires_in option in 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"

like image 997
Pierre Valade Avatar asked Dec 02 '10 01:12

Pierre Valade


1 Answers

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.

like image 82
molf Avatar answered Oct 18 '22 11:10

molf