Is there a way to refresh a fragment cache in a way that allows reads from the cache while the update is taking place?
I'm caching a part of an html.erb view in Rails with the cache do .. end
block in erb.
I'm expiring the same cache in the controller, with a call to expire_fragment(:controller => 'controllername')
I'm using memcached as the fragment cache store.
I could be wrong, but it looks like the default behavior is that the moment you call expire_fragment
the fragment is deleted from the cached, so another request a split second after that for the same fragment will miss the cache.
What I would really like is for reads from the cache to keep taking place right up until the new fragment is computed and saved in the cached, at which point all subsequent requests get that new cached version.
This particular fragment is expensive to calculate. It take about 7 seconds.