How long Celery stores results, can I limit this time

Viewed 555

I want to use Сelere with Redis as backend, I'll have a process that create tasks, stores ids and then runs again and checks statuses. How to clear results and statuses that I don't need anymore, could I restrict time Сelery stores result ?
Like this:

task_id = task.apply_async().id
store_id(task_id) # my code, doesn't relate to celery

Then I will get tasks and check statuses:

task_id = get_id() # my code, doesn't relate to celery
task = AsyncResult(task_id)
# do something with task
# now I don't need Celery to store this result
2 Answers

Celery save the result for a day by default.

You can however adjust this value with result_expires.

Here are the docs.

Default: Expire after 1 day.

Time (in seconds, or a timedelta object) for when after stored task tombstones will be deleted.

You can mention this in your settings.py

CELERY_RESULT_EXPIRES = 360

here i limit the expire time to 1 hour. but default value for this is one day.

Related