zackaj/laravel-debounce
Debounce Laravel jobs, notifications, and (Laravel 11+) Artisan commands to prevent spamming users and queues. Uses unique job locks + cache to delay execution until activity stops. Tracks each occurrence with request metadata (IP, user) and provides reporting.
php artisan cache:clear) resets all debounced tasks. Requires explicit handling in deployments.composer require zackaj/laravel-debounce
php artisan vendor:publish --tag=laravel-debounce-config
LARAVEL_DEBOUNCE_ENABLED=true in .env.config/debounce.php (default: cache).Debounce::job()) for existing code.make:debounce-job) for advanced features (reporting, hooks).DebounceJob, DebounceNotification, or DebounceCommand for reporting/hooks/timestamp overrides.LARAVEL_DEBOUNCE_ENABLED) for emergencies.Cache::lock() timeouts).user_id:123) if contention is observed.php artisan queue:failed
php artisan telescope:prune
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache failure (e.g., Redis down) | Debounced tasks execute immediately or fail silently. | Fallback to immediate execution with logging. |
| Queue worker crashes | Debounced tasks pile up. | Monitor queue length; scale workers. |
| Cache flushed | All debounced tasks reset. | Warn admins; implement soft resets. |
| Lock contention | Tasks delay indefinitely. | Use Redis with PX locks; test under load. |
| Laravel upgrade | CLI debouncing breaks in v10. | Feature flag for CLI debouncing. |
Cache::lock() and Queue::later().LARAVEL_DEBOUNCE_ENABLED=false in dev).How can I help you explore Laravel packages today?