You could probably hook up something similar using ActiveSupport::Notification and instrumenting the create action in the Posts controller, or alias_method_chain the create method on Posts to do what you want.
On Aug 1, 2012, at 4:27 PM, mcasimir <[email protected]> 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. > > 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? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/9cOxfQkvlu4J. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-core?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
