Removing finished jobs
By default, BullMQ will keep all completed and failed jobs. Most likely you will want to limit to sane amounts in order to not fill up your Redis™ database with older jobs.
The workers support two options that can be used to specify the behaviour of completed and failed jobs:
The "count" field specifies the maximum number of jobs to keep, whereas the "age" specifies the maximum age in seconds of the jobs to keep. You can use any of these options standalone or combined.
Note that the removal of jobs is lazy. So older jobs will only be removed if new jobs are completed or failed.
Lets update our endpoint so that we only keep the latest 1000 completed jobs, and no failed jobs older than one day but never keep more than 5000:
Last updated