delay_jobs保存已完成的工作 [英] delayed_jobs save completed jobs

查看:58
本文介绍了delay_jobs保存已完成的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个我可以传递给delay_job的参数,可以防止它从delay_jobs表中删除已完成的作业?

Is there a parameter I can pass to delayed_job that will prevent it from deleting completed jobs from the delayed_jobs table?

类似于 destroy_failed_jobs 但对于已完成的工作

kind of like the destroy_failed_jobs but for completed jobs

有什么想法吗?

推荐答案

它没有出现。从自述文件中: https://github.com/tobi/delayed_job

It doesn't appear so. From the README: https://github.com/tobi/delayed_job


默认情况下,它将删除失败的作业(并且总是删除
成功的作业)。如果要保留失败的作业,请设置
Delayed :: Job.destroy_failed_jobs = false。失败的作业将被标记为
并标有非null failed_at。

By default, it will delete failed jobs (and it always deletes successful jobs). If you want to keep failed jobs, set Delayed::Job.destroy_failed_jobs = false. The failed jobs will be marked with non-null failed_at.

您可能需要使用其destroy方法,例如它将其复制到另一个单独的表中,该表可以为您保留已完成的作业列表,或者如果您只需要日志,则可以简单地将已完成的作业记录到文件中。

You would probably need to hook into its destroy method such that it copies the job to another, separate table that keeps the list of completed jobs for you, or to simply log which jobs have been done to a file, if a log is all you need.

您不希望将作业留在 delayed_jobs 表中,原因有两个。首先,由于 delayed_jobs 使用该表作为其TODO列表-您希望它仅是仍有待完成的事情。其次,如果您对其进行黑客攻击以将所有作业保留在同一表中,则 delayed_jobs 表只会增长,这会减慢 delayed_jobs 随着时间的流逝,因为要查找尚未完成的工作的查询将不得不过滤出​​已完成的工作

What you don't want is to leave the jobs in the delayed_jobs table, for a couple of reasons. First, because delayed_jobs uses that table as it's TODO list - you want it to only be things that still need to be done. Second, if you hacked it to keep all jobs in the same table, then the delayed_jobs table only grows, which would slow down the processing of delayed_jobs over time, as the query to find jobs that have not yet been completed would have to filter out those that have.

这篇关于delay_jobs保存已完成的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆