[Backgroundrb-devel] Scheduling one-off tasks

hemant gethemant at gmail.com
Tue Jul 22 01:04:58 EDT 2008

On Tue, Jul 22, 2008 at 2:23 AM, Joost Baaij <joost at spacebabies.nl> wrote:
> I am building a Rails website which has content that expires at some time in
> the future.
> Since this content is cached, by the time it expires I would like a method
> to sweep the cache at that time. Since it's based on a date, I cannot use
> the Rails app itself. I could use polling or sweep the cache every 5
> minutes, but maybe there's a better approach?
> I would like to know if I can use backgroundrb's at/cron-like features to
> schedule one-off execution of a piece of code at a date/time in the future.
> This would be a sweeper that runs at the expires_at time of my content.
> I realise I can build a worker that goes into a sleep/wait loop until the
> desired time, but that's not really better than polling.

You don't need an explicit sleep in worker, it will wait anyways on select().

Also, by "one off", you mean, a worker that starts when on schedule
and stops after that, you can use "reload_on_schedule true" in worker.

More information about the Backgroundrb-devel mailing list