Reputation: 621
Question:
@task(name='task_name')
?Upvotes: 1
Views: 852
Reputation: 19787
Does celery clear results in redis after a set number of days?
Yes
Is there a celery option to keep only the latest task result in redis in the task decorator @task(name='task_name')?
As far as I know, there is no such option.
Is there an option to save only the last X number of task results in redis memory?
No.
Celery authors decided (I think it was a good decision) to give us ability to control for how long task results are persisted (see result_expires configuration parameter for more details). By default it is set to one day. - Celery users should tweak this setting according to their needs.
If you still see the task results from 5 days ago that means that either you changed the default configuration parameter, or you are not using result backend for which there is no support for task result expiration. Here is a note from the section I mentioned above:
For the moment this only works with the AMQP, database, cache, Couchbase, and Redis backends.
When using the database backend, celery beat must be running for the results to be expired.
Upvotes: 1