Prevent duplicate jobs from being added by using job IDs
Sometimes, you may want to enqueue a job in reaction to a frequently occurring event, without running that job for every event. For example, you may want to send an email to a user when they update their profile, but you don’t want to send an email for every single update if they make many changes in rapid succession.
You can achieve this by setting an identical jobId so that identical jobs are considered duplicates and not added to the queue.When you use this option, it is up to you to ensure the jobId is unique for different types of work:
In this example, only the first job will be added to the queue. All subsequent attempts to add a job with the same jobId will be ignored while a job with that ID exists in the queue.
Be careful if using removeOnComplete/removeOnFailed options, since a removed job will not count as existing and a new job with the same job ID could be added to the queue without being detected as a duplicate.