Reputation: 15259
I am using Ruby on Rails 3 and I would like to increase the expiration time for a cache key during the execution time. I use memcached.
For example, I have
Rails.cache.write("key_test", "value_test", :expires_in => 10.seconds)
so that the key_test
will expire in 10 seconds. In order to make available that key value for longer, what I can do? Is it possible to increase only the expires_in
without to set again the value_test
?
The following code doesn't work, but maybe I have to do something like this:
Rails.cache.write("key_test", :expires_in => 10.seconds)
Upvotes: 2
Views: 2426
Reputation: 14189
This will work:
Rails.cache.write('key_test', Rails.cache.read('key_test'), :expires_in => 10.seconds)
Upvotes: 4