有一个控制器处理大型 XML 提要的呈现
module Spree
class FeedsController < Spree::StoreController
...
caches_action :products_out
cache_sweeper FeedSweeper
# XML feed in format of `xxxxxxx.com'
def products_out
@products = Product.all
respond_to do |format|
format.xml
end
end
end
波纹管是相应的清扫器的子类:
module Spree
class FeedSweeper< ActionController::Caching::Sweeper
observe Product
def after_update(product)
# cache_configured? is nil, @controller is nil here, why ?
expire_action(:controller => :feeds,
:action => :products_out,
:format => :xml)
end
end
Spree::FeedSweeper
更新时调用上面的方法Spree::Product
,但是它似乎expire_action
默默地死掉并且缓存不会失效。
有人可以解释这个问题吗?更好地提出一些解决方案?
谢谢。