我对Celery来说很新,我以为我已经读过某个地方,任务结果只能在有限的时间内保持不变。 然而,在通过它执行大量任务后,我的后端(redis)变得非常臃肿。
有没有办法在任务结果上设置TTL,还是我需要手动清除(以及如何)?
I am pretty new to Celery and I thought I had read somewhere that the task results only stay around for a limited time. However my backend (redis) is getting pretty bloated after running a lot of tasks through it.
Is there a way to set a TTL on task results or is this something I need to manually purge (and how)?
最满意答案
根据celery文档,您可以使用CELERY_IGNORE_RESULT完全忽略所有结果。
您还可以使用CELERY_TASK_RESULT_EXPIRES在一段时间后使结果到期,默认为1天。 它说这应该只适用于redis后端,而其他一些后端需要celery beat才能运行。
还有CELERY_MAX_CACHED_RESULTS设置,默认情况下最多可缓存5,000个结果。
According to the celery documentation you can completely ignore all results using CELERY_IGNORE_RESULT.
You can also expire results after a set amount of time using CELERY_TASK_RESULT_EXPIRES, which defaults to 1 day. In the notes it says this should just work with the redis backend, whereas some of the other backends require celery beat to be running.
There is also the CELERY_MAX_CACHED_RESULTS setting that caches up to 5,000 results by default.
更多推荐
发布评论