On Wed, Aug 01, 2012 at 04:27:48PM -0700, mcasimir wrote:
> Hi,
> I wish to ask you if could be a good idea to introduce in Rails a simple 
> complement to Sweepers that could reduce the effort of expiring cache, 
> something like that:
> 
> Rails.cache.fetch("recent_posts", :expires_when => [:create, Post])
> 
> The above example could setup a callback to expire "recent_posts" each time 
> that a Post is created.

I'm not really a fan of this.  When I read this code, it's difficult to
understand how ":create" is related to "Post".  The other problem is
that if I were to read the file that defines Post, I would not be able
to understand the impact of Post on the entire system.

> Sometimes I would like to rely on something like that to expire cache in 
> place of sweepers/observers.
> What do you think? There may be downsides with this approach?

Can you explain the problem you're trying to solve?  Maybe we can work
from there to come up with a better solution.

-- 
Aaron Patterson
http://tenderlovemaking.com/

Attachment: pgpzqneADUqqD.pgp
Description: PGP signature

Reply via email to