Scaling Rails with Cache-on-write
I currently have a rails app that uses the traditional caching. cache do
blocks are used to cache slow-rendering partials. This works great for the most part, except for a few pages which take too long to render on t开发者_如何学Pythonhe first read.
I'd like to move the rendering of these partials to the write-side from the read-side, by rendering in either the model or in sweepers when the underlying data changes. Preferably, this would be in the sweepers that already invalidate the cache keys. Is this a good approach? Is there a "right" way to do this?
Is it the actual partial that is taking a while to render or the queries required to actually get the data? If it's the latter you're better off caching those in a write-through manner, it might be simpler than trying to update cached partials on write.
精彩评论