Expiring cache fragments using script/runner


#1

I’ve just set up caching on my site and want to expire some of fragments
on
an hourly basis.

I was going to use cron and script/runner to do this.

For other fragments that I am expiring, I am using expire_fragment
inside a
sweeper class, something like:

class QuestionSweeper < ActionController::Caching::Sweeper
observe Question

def after_validation_on_update(question)
expire_page :controller => ‘xml’, :action => ‘question’, :id =>
question.id
expire_all_recently_added
end

def expire_all_recently_added
expire_fragment :controller => ‘landing’, :action => ‘last_added’,
:part
=> ‘list’
end
.
What I am stumped on is that I want to use script/runner which works on
models, and expire_fragment which works in controllers.

Can someone provide an example of how they would expire the fragment and
how
it would be called by script/runner?

Thanks,

Steve
http://www.smarkets.net