# Problem using rake to expire caches

**URL:** <https://www.ruby-forum.com/t/problem-using-rake-to-expire-caches/124902>\
**Category:** Rails\
**Created:** [January 3, 2008, 5:23pm UTC](https://www.ruby-forum.com/t/problem-using-rake-to-expire-caches/124902 "2008-01-03T17:23:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/6a8cbe/32.png) [@vinay](https://www.ruby-forum.com/u/vinay)\
**Post date:** [January 3, 2008, 5:23pm UTC](https://www.ruby-forum.com/t/problem-using-rake-to-expire-caches/124902/1 "2008-01-03T17:23:29Z")

</div>

I am trying to expire a fragment cache in rake. I know that the best  
practice to expire the cache is in the Sweepers. But as I have to  
expire  
the cache at the end of the month I was thinking on the lines of doing  
it in a rake task.  
I had tried this but it showed me an error while running the task

expire\_fragment(:controller =\> :login, :action =\> :index, :something=\>  
“1”)

Well it gives me a “No method Error”

Wanted to know what is the best practice to clear the cache on a cron  
job? Should a sweeper action be called or a rake task is prescribed?

If any one has done this would highly appreciate if he/she could  
provide  
the code for calling a sweeper action from a cron or can someone point  
out what I am missing in the rake file. Do I have to create an object  
and then call the method if so then an object of what class?

Please pardon me for being such a newbie. Any help would be highly  
appreciated.

Cheers,  
Jazzy
