I'm trying to expire a cached fragment when a model is updated. The
usual way to do this is with a sweeper, but sweepers only work when an
action is being called at the same time - I need to expire a cached
fragment during some back-end batch process.
A normal observer should work, but you don't have access to the
expire_fragment method from there.
Adding "include ActionController::Caching::Fragments" in my observer
gives me access this method, but re-runs the fragment_cache_store
initialise method and resets my config to the default MemoryStore.
I have a few options, (such as: copy and paste the expire_fragment
method into my observer, reconfig the fragment_cache_store after
inclusion, make my batch process make a http call to a controller
action to kill the cache), but these all seem pretty ugly.
Does anyone know if there is an easier way to get access to this
method from within my observer?