我在应用程序中有一些问题将过期缓存。使用自定义缓存路径到期操作缓存
这里是我的控制器:
class ToplistsController < ApplicationController
caches_action :songs, cache_path: :custom_cache_path.to_proc
def custom_cache_path
"#{params[:when]}-#{params[:what]}-#{params[:controller]}-#{params[:action]}"
end
def songs
# ...
end
end
不知何故,我需要能够重置自定义缓存路径,但我无法弄清楚如何。
我已经尝试过使用this technique,但没有成功。它看起来像Dalli,这是我的缓存引擎,不支持正则表达式匹配器。
尝试使用此代码时,我得到这个错误:
expire_fragment(/songs/)
ActiveSupport::Cache::DalliStore does not support delete_matched
我试着使用这行代码,用于调试,但它被忽略。
before_filter only: [:songs]
expire_fragment(custom_cache_path)
end
我使用的是Rails 3.1.0.rc6,Dalli 1.0.5和Ruby 1.9.2。
你使用正则表达式与达利奇与这个宝石:https://github.com/defconomicron/dalli-store-extensions –
我会试试看,谢谢。 – Oleander