管理芹菜任务结果(Managing Celery Task Results)

编程入门 行业动态 更新时间:2024-10-26 08:35:11
管理芹菜任务结果(Managing Celery Task Results)

我对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.

更多推荐

本文发布于:2023-07-23 00:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1225234.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:芹菜   Managing   Celery   Task   Results

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!