# lib/cacher.rb module Cacher STORE = {} def cache(*args) STORE[args.inspect] ||= yield end def flush! STORE.clear end module_function :flush! end # app/models/person.rb class Person < AR::Base include Cacher def finger cache(:finger, email) do `finger #{email}` end end end # app/controller/application.rb class ApplicationController < AC::Base after_filter { Cacher.flush! } end
You need to create an account or log in to post comments to this site.