Dinesh Uprety
@dineshuprety ·
Public
Debounce Queued Event Listeners
JAVASCRIPTProcess only the newest event when several events arrive during a short period.
JAVASCRIPT
CodeSnap // free canvas
Debounce Queued Event Listeners
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\Attributes\DebounceFor;
#[DebounceFor(30, maxWait: 120)]
class UpdateProductSearchIndex implements ShouldQueue
{
public function debounceId(ProductUpdated $event): string
{
return (string) $event->product->getKey();
}
}