0
@@ -27,13 +27,15 @@ module ActionController #:nodoc:
0
# You can set modify the default action cache path by passing a :cache_path option. This will be passed directly to ActionCachePath.path_for. This is handy
0
# for actions with multiple possible routes that should be cached differently. If a block is given, it is called with the current controller instance.
0
- # And you can also use :if to pass a Proc that specifies when the action should be cached.
0
+ # And you can also use :if (or :unless) to pass a Proc that specifies when the action should be cached.
0
+ # Finally, if you are using memcached, you can also pass :expires_in.
0
# class ListsController < ApplicationController
0
# before_filter :authenticate, :except => :public
0
# caches_action :index, :if => Proc.new { |c| !c.request.format.json? } # cache if is not a JSON request
0
- # caches_action :show, :cache_path => { :project => 1 }
0
+ # caches_action :show, :cache_path => { :project => 1 }
, :expires_in => 1.hour0
# caches_action :feed, :cache_path => Proc.new { |controller|
0
# controller.params[:user_id] ?
0
# controller.send(:user_list_url, c.params[:user_id], c.params[:id]) :
0
@@ -56,8 +58,10 @@ module ActionController #:nodoc:
0
def caches_action(*actions)
0
return unless cache_configured?
0
options = actions.extract_options!
0
- cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path))
0
- around_filter(cache_filter, {:only => actions}.merge(options))
0
+ filter_options = { :only => actions, :if => options.delete(:if), :unless => options.delete(:unless) }
0
+ cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options)
0
+ around_filter(cache_filter, filter_options)
0
@@ -80,8 +84,8 @@ module ActionController #:nodoc:
0
- cache_path = ActionCachePath.new(controller, path_options_for(controller, @options))
0
- if cache = controller.read_fragment(cache_path.path)
0
+ cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path)))
0
+ if cache = controller.read_fragment(cache_path.path, @options[:store_options])
0
controller.rendered_action_cache = true
0
set_content_type!(controller, cache_path.extension)
0
options = { :text => cache }
0
@@ -96,7 +100,7 @@ module ActionController #:nodoc:
0
return if controller.rendered_action_cache || !caching_allowed(controller)
0
action_content = cache_layout? ? content_for_layout(controller) : controller.response.body
0
- controller.write_fragment(controller.action_cache_path.path, action_content
)
0
+ controller.write_fragment(controller.action_cache_path.path, action_content
, @options[:store_options])