3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/action_controller/macros.rb', line 3
def self.active_cache(action, *args)
args = args.
state, condition, expires = args[:state], (args[:if] || lambda{ true}), args[:expires_in]
before_filter({:only => action}) do |c|
return unless condition.call(c)
if p = ActiveCache::cache_store.read(state.call(c).merge!({:action => action}))
logger.debug "Rendered from memory"
render(:text => p)
end
end
after_filter({:only => action}) do |c|
return unless condition.call(c)
ActiveCache::cache_store.write(state.call(c).merge!({:action => action}), response.body, expires)
end
end
|