I added some new functionality to the memcachedb_q plugin to allow for repeatable calls.

q = MemcachedbQ.new(:email)
q.add_runner(:mail, :get_emails, :repeats=>30, :repeat_name=>”email”)

This repeats the Mail.get_emails call every 30 seconds. Using the repeat name makes sure that there is only 1 repeating call with the same name. The repeats work by adding a new item to the queue with a future run date just before the existing one fires off and is removed. The future date is based on the :run_time value plus the repeat value in seconds. If a run_time value is not provided the first repeat sets it’s on run_time value based off Time.now.

Also if you add a runner with a run time date in the past, it will only add a runner in the future for the next time it would have matched :run_time + repeat*x. That way if the scheduler ever dies or is shut down, it won’t have a huge list of runners to go through before it catches up to real time.