[25] pry(main)> Rails.cache.fetch("my_key", :expires_in => 1.year) do
[25] pry(main)* (Time.now.to_date).to_s
[25] pry(main)* end
=> "2013-11-01"
[28] pry(main)> Rails.cache.fetch("my_key")
=> nil
I cant understand the above behavior. The cache does not have this key before this, or rather it is nil
.
This works fine if I remove the expires_in
option.
This is in the production version of my app which uses memcached
# Use a different cache store in production
config.cache_store = :mem_cache_store, <DNS NAME>
This also works on my local which I expect is the filesystem based caching.
Edit: ah, 1.year
is too long perhaps.. It works with 1.day
. Is this a bug or is this documented somewhere?
Edit: It appears that 1.month
is the max in a duration form. But this still cant be accepted behavior
Memcache maximum key expiration time