是否有一种方法可以通过命令行在Celery中删除所有以前的任务结果?我能找到的所有内容都是参考,但似乎不适用于任务结果。我找到的其他解决方案包括使用Celery beat定期删除它,但我正在寻找一次性的命令行解决方案。
我使用的是Celery 4.3.0。
这里是我认为你在寻找的内容:
https://github.com/celery/celery/issues/4656
引用https://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_expires
我如下设置:RESULT_EXPIRE_TIME = 60 * 60 * 4 # keep tasks around for four hours
...
celery = celery.Celery('tasks',
broker=Config.BROKER_URL,
backend=Config.CELERY_RESULTS_BACKEND,
include=['tasks.definitions'],
result_expires=RESULT_EXPIRE_TIME)
根据这个答案:
使用redis-cli:
FLUSHDB - Removes data from your connection's CURRENT database.
FLUSHALL - Removes data from ALL databases.
Redis 文档:
flushdb
flushall