Support the ongoing development of Laravel.io →
Queues

Sometimes a non-trivial Queue operation can occasionally be triggered more than once before the first one is complete, which in some cases would make working the second queue redundant/waste of resources. Does Laravel has a Queue driver agnostic solution (e.g. redis, pheanstalk) to ensure unique queues? It looked "cheap" to do this in a Redis Queue, but if I needed it in any Queue driver, would it be an expensive check?

For example if Queue::push('FooQHandler@rebuildFooCache',['foo_id'=>12]); is called twice and the queue is logged, there could be the following in the queue:

FooQHandler@rebuildFooCache, [foo_id=>10] <-- next to be worked by queue
FooQHandler@rebuildFooCache, [foo_id=>11]
FooQHandler@rebuildFooCache, [foo_id=>12]
FooQHandler@laySomeBricks,   [foo_id=>10]
FooQHandler@rebuildFooCache, [foo_id=>14]
FooQHandler@rebuildFooCache, [foo_id=>12] <-- new duplicate

So for me it would be cool if something like this existed:

Queue::push('FooQHandler@rebuildFooCache',['foo_id'=>12])->unique();
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

IOM instanceofmichael Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.