问题描述
|
有什么方法可以使用rake任务重置操作缓存?
我在控制器中有一个动作,可以显示前100首歌曲。
我只需要每24小时生成一次视图。
解决方法
这是我的解决方案。
控制者
helper_method :custom_cache_path
before_filter only: [:method] do
if params[:reset_cache]
expire_fragment(custom_cache_path)
end
end
def custom_cache_path
\"#{params[:id].to_i}-#{params[:controller]}-#{params[:action]}\"
end
休息请求
RestClient.get \"http://example.com/controller/method?reset_cache=1\"