uggedal / merb_cache_observer
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
06bb86d
merb_cache_observer / README.markdown
| b2457d55 » | uggedal | 2008-07-29 | 1 | Merb cache observer | |
| b58ca7f3 » | uggedal | 2008-07-29 | 2 | =================== | |
| 3 | |||||
| 4 | A plugin for the Merb framework that provides easy integration of model | ||||
| 5 | observers for DataMapper which will expire caches. | ||||
| 6 | Based on [Cache watch][1] by nutrun. | ||||
| 7 | |||||
| 8 | Works on page caches for now. The cache is expired when the provided | ||||
| 9 | model class is saved or destroyed. | ||||
| 10 | |||||
| 11 | Imagine we have a People controller with an index page shortly listing all | ||||
| 12 | people in the system. The show page lists detailed account information | ||||
| 13 | for any person. We then want to invalidate the page cache for the index page | ||||
| 14 | when the person model is changed. | ||||
| 15 | |||||
| 1cf37873 » | uggedal | 2008-07-29 | 16 | class People < Merb::Controller | |
| 17 | cache_pages :index, :show | ||||
| 18 | observe_pages [:index, Person], [:show, Person, Account] | ||||
| 19 | end | ||||
| b58ca7f3 » | uggedal | 2008-07-29 | 20 | ||
| 21 | There is also a singular counterpart to cache_page: | ||||
| 22 | |||||
| 1cf37873 » | uggedal | 2008-07-29 | 23 | class Entries < Merb::Controller | |
| 24 | cache_page :index | ||||
| 25 | observe_page :index, Entry, Comment | ||||
| 26 | end | ||||
| b58ca7f3 » | uggedal | 2008-07-29 | 27 | ||
| 28 | |||||
| 29 | [1]: http://nutrun.com/weblog/cache-watch/ | ||||
