Thursday, October 2, 2008

how to set ttl for rails fragments when using memcache

since I couldn't find this documented anywhere heres how you do it:


<% cache(key, :expires_in => 10.minutes) do %>
this gets cached! then expires after 10 minutes!
<%end%>


assumptions: you're running rails 2.1 (i can't vouch for rail 2.2 or 2.0 or anything else)
you're using memcache to keep your fragments

ActionController::Base.cache_store = :mem_cache_store



maybe this will come up for someone else google and save them 20 minutes.

0 comments: