Memcached (Dalli) and expiration time for caches_action
-
08-07-2021 - |
Question
I'm using Memcached and Dalli store for my rails app.
Is there a way to set something like expires_in
and gzip
for caches_action
?
Solution
Just add them to the caches_action
invocation line as cache parameters; all parameters that are not specific to caches_action
will be passed to the actual memcache fetch
call.
caches_action :show, :unless => proc {current_user},
:cache_path => proc {"post_#{params[:id]}"},
:expires_in => 10.seconds,
:race_condition_ttl => 2.seconds
I use Dalli and Rails 3.1.3, and this code works as intended. I suppose, gzipping would also work.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow