title: Rails 3: invalidating a cache outside of a controller
body: <p>I have certain pieces of data that are updated infrequently - say, once every few weeks or so. Additionally, they're shared amongst users, and can take some time to render as JSON. This makes them ideal to cache. So, I cache their rendered output via <code>caches_action</code>.</p>
  
  <p>Soon, I'll be updating this data from a Resque job, and after updating it successfully, I will need to invalidate the cache. I'm not sure where to do this, as it seems like the job of the controller. It doesn't seem right to put it in the model, as its more of a presentation layer concern. (After all, why should the model care that JSON output takes forever?)</p>
  
  <p>I don't think a sweeper would work here, as it operates within a controller, correct? I've seen people suggest instantiating the controller in question within the job, but that really isn't nice either. Has anyone dealt with this in a DRY-ish way? The only way I see to do it is to manipulate <code>Rails.cache</code> manually.</p>