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.
queue:work). Projects using synchronous task execution may need adjustments.php artisan cache:clear) resets debounce state, potentially causing duplicate executions. Mitigation: Use a persistent cache driver (e.g., Redis) or implement a fallback mechanism.uniqueKey values (e.g., static strings) may lead to unintended debouncing. Mitigation: Use dynamic keys (e.g., user()->id, request()->ip()).uniqueKey values be generated? Are they user-specific, request-specific, or static?LARAVEL_DEBOUNCE_ENABLED toggle for testing.)SETNX).LARAVEL_DEBOUNCE_ENABLED=false to verify fallback behavior.php artisan vendor:publish --tag=laravel-debounce-config).composer.json and run composer require zackaj/laravel-debounce.Debounce::notification()).config/debounce.php file and .env toggle.getReport() data for auditing (e.g., occurrences->count()).failed_jobs table.uniqueKey values are unique and meaningful.getReport() calls).jobs table growth.uniqueKey spaces (e.g., per-millisecond timestamps) may strain cache memory.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Cache driver failure | Debounced tasks may execute multiple times. | Use Redis with persistence or fallback to database cache. |
| Queue worker crashes | Debounced tasks are delayed or lost. | Implement a dead-letter queue and health checks for workers. |
| Cache flushed manually | Debounce state is lost. | Use a persistent cache driver or implement a backup mechanism (e.g., DB table). |
Poor uniqueKey design |
Incorrect debouncing (e.g., all users share one key). | Use dynamic, granular keys (e.g., user_id + action_type). |
| Laravel upgrade incompatibility | Package breaks with new Laravel version. | Test in staging; use version constraints in composer.json. |
| High-frequency debounced tasks | Cache bloat or queue congestion. | Increase cache TTL or debounce intervals; monitor with Telescope. |
uniqueKey design (e.g., when to use user()->id vs. request()->ip()).How can I help you explore Laravel packages today?