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"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With