2011-04-13 2 views
0

rake 작업을 사용하여 작업 캐시를 재설정하는 방법이 있습니까?rake 작업에서 작업 캐시 재설정

내 컨트롤러에서 톱 100 곡을 보여주는 액션이 ​​있습니다. 24 시간마다 한 번만보기를 생성하면됩니다.

답변

1

내 해결책은 다음과 같습니다.

컨트롤러

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" 
관련 문제