cashier
cashier copied to clipboard
Containers support
- Support ActiveRecord as tag ("#{obj.class.name}-#{obj.to_param}")
- Detect dependencies of fragments containing other fragments, e.g., several article fragments displayed in a section fragment, and when the inner fragment is expired also expire its containers. In the example, today changing one of the articles' title won't be reflected in the section, since it's cached. The feature allows tagging the article fragment with the article object, then on_save call Cashier.expire(self), which will also expire the section.
How is this better than Rails 4's support for russian doll caching?
Russian doll mainly handles changes to the view file.
Let's say we have models section and article. The section view contains multiple article partials, and the section view is cached in full.
If a change is made to an article, the partial will expire, but not the full section view - it will still show the old version of the article. In order for the section view to expire, every change to an article should "touch" all the sections it's displayed on, which could be a costly operation, not to mention it's not a true business need - we'll be doing it only for view purposes.
This concept is very similar to that I have implemented in https://github.com/brain-geek/activerecord_cashier - though activerecord_cashier also has mechanism to automaticaly trigger cache expiration on model save.
And it is also based on cashier - but in complementary way.