Iam正在使用Rails應用程序,並使用Dalli將緩存與memcache集成。 Iam正在使用清掃器來處理動作緩存和到期緩存。 我掃地機的代碼如下所示:Rails在Memcache中使用regex表達式使行爲過期
class BoardSweeper < ActionController::Caching::Sweeper
observe Board
def after_create(board)
expire_cache(board)
end
def expire_cache(board)
expire_action :controller => :boards, :action => :show, :id => "#{board.id}-#{board.title.parameterize}"
end
end
但我想用正則表達式表達刪除緩存即我想匹配的URL,並刪除緩存就像:
如果我的板顯示的URL是像:
"boards/1/likes-collection-of-branded-products.text/javascript"
"boards/1/likes-collection-of-branded-products.text/html"
然後我想用下面的表達式到期緩存:
Rails.cache.delete_matched(/boards\/1.*/)
但是按照它不支持的memcache api doc delete_matched方法。
Iam肯定應該有一些方法來刪除基於正則表達式。請幫忙。
很多感謝!