我有我的 resque_scheduler 设置运行清理任务每 2 分钟。清理任务将在 2 分钟间隔内清理项目。这是我的 yml:
scheduled_tasks:
cleanup:
class: "BackgroundJobs::Cleanup"
every: "120s"
description: "cleans up items in the 2 min interval"
这是工作
module BackgroundJobs
class Cleanup
@queue = :cleanup
def self.perform(options = {})
# do cleanup here
end
end
end
工作队列很好,并且被很好地拿起。但是,在执行中,它需要知道应该清理的时间段。例如,如果有东西在 2:32 排队,我希望它在 2:30 到 2:32 之间清理项目。但是,工作可能要到很久以后才会被接手,例如 2:35。我没有关于它何时排队的信息。有没有办法做到这一点?