cache_fuやmemcachedを使うときに、cacheメソッドがオプションを 受け取ってくれないので不便だなと思っていたのですが、 EdgeRailsでは以下のようなパッチが当たっていて この問題は解決されているようです。
[PATCH] Rails have poor support to work with memcached
Let's assume we have a caching installati
on with Nginx used as a frontend. Nginx attempts to get page body by key from memcached. If it succeeds (meaning that the page is in memcached), Rails doesn't get control, making this schema extremely fast, up to 3K requests per second. In case memcached doesn't contain cached page by url as a key, Rails receive control, render page and cache it in memcached in order for the next request to be retrieved from memcached.
現状のリリースバージョンのコードでは、以下のようになっています。
vendor/rai
1 def cache(name = {}, &block) 2 @controller.cache_erb_ fragment(block, name) 3 end
これが、EdgeRailsでは以下のように変更されています。
vendor/rai
1 def cache(name = {}, options = nil, &block) 2 template_extension = first_rend er[/\.(\w+)$/, 1].to_sym 3 4 case template_e xtension 5 when :erb, :rhtml 6 @controller .cache_erb_ fragment(block, name, options) 7 when :rjs 8 @controller .cache_rjs_ fragment(block, name, options) 9 when :builder, :rxml 10 @controller .cache_rxml _fragment(block, name, options) 11 else 12 # do a last ditch effort for those brave souls using 13 # different template engines. This should give plugin 14 # writters a simple hook. 15 unless @controller .respond_to ?("cache_#{template_e xtension}_fragment") 16 raise "fragment caching not supported for #{template_e xtension} files." 17 end 18 19 @controller .send!("cache_#{template_e xtension}_fragment", block, name, options) 20 end 21 end