uggedal / merb_cache_observer

Observes DataMapper models and expires Merb caches on changes

This URL has Read+Write access

merb_cache_observer / README.markdown
b2457d55 » uggedal 2008-07-29 Underscores does not go wel... 1 Merb cache observer
b58ca7f3 » uggedal 2008-07-29 Initial idea. 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 Code blocks are indented in... 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 Initial idea. 20
21 There is also a singular counterpart to cache_page:
22
1cf37873 » uggedal 2008-07-29 Code blocks are indented in... 23 class Entries < Merb::Controller
24 cache_page :index
25 observe_page :index, Entry, Comment
26 end
b58ca7f3 » uggedal 2008-07-29 Initial idea. 27
28
29 [1]: http://nutrun.com/weblog/cache-watch/