Volatile cache keys with Rails and Redis

19 views
Skip to first unread message

bricker

unread,
Nov 3, 2012, 12:34:41 AM11/3/12
to rubyonra...@googlegroups.com
Does Rails automatically set an EXPIRE attribute on keys when working with Redis, or will an old key sit there forever if it's never manually cleared out? This is mostly a concern when using ActiveModel's "cache_key":

<%= cache @post do %>

The cache-key will be something like views/posts/744-20120613070958 . When the post is updated, and therefore gets a new cache-key, what happens to the old one? Will it just sit there forever? Do I need to add an `expires_in` option to every cache call, just to make sure it gets cleaned up every once in a while?

<%= cache @post, expires_in: 1.month do %>

Thanks,
Bryan

Jeffrey Jones

unread,
Nov 4, 2012, 10:16:52 PM11/4/12
to rubyonra...@googlegroups.com
The idea is that your cache system should expire the oldest items in the
cache automatically when it hits its pre-configured size limit.
Reply all
Reply to author
Forward
0 new messages