9

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)?

jwarzech
  • 6,596
  • 11
  • 52
  • 72

1 Answers1

15

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_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.

Demetris
  • 2,981
  • 2
  • 25
  • 33
Chris Ward
  • 774
  • 5
  • 6
  • `CELERY_TASK_RESULT_EXPIRES` should actually be `CELERY_RESULT_EXPIRES`. https://docs.celeryproject.org/en/stable/userguide/configuration.html – Ruhi123 Apr 28 '21 at 12:53