zaber-dev/laravel-cooldown
Laravel Cooldown manages persistent, entity-scoped action cooldowns for Laravel apps. Enforce limits on workflows, routes, and Eloquent models using cache or database storage, with atomic execution, middleware, and custom backends.
Architecture fit
Integration feasibility
composer require, auto-discovery, publishable config, and (for DB storage) publishable migrations. A competent Laravel engineer can produce a working pilot in days, not weeks.Technical risk
SET NX/Lua, DB unique constraints/transactions). A non-atomic implementation permits burst bypass under load — the exact condition cooldowns exist to prevent.maxmemory pressure. That is acceptable for "don't spam the button" and unacceptable for fraud, billing, or security windows.429/Retry-After behavior is a real client-contract risk if both layers are active on the same route.Key questions
429, Retry-After, custom message) that can be localized and documented for API consumers?Stack fit
| Layer | Fit | Notes |
|---|---|---|
| Laravel 11–13, PHP 8.2+ | Strong | Aligns with actively supported framework lines; blocks older LTS estates |
| Redis / Memcached | Strong | Natural home for ephemeral cooldowns |
| Database storage | Moderate | Durable but adds write amplification and a pruning obligation |
| Eloquent | Strong | Per-model guards without bespoke schema |
| Middleware | Strong | Declarative route protection, easy code review |
Migration path
throttle usage; classify each as security-critical (must be durable/atomic) or UX friction (cache is fine).Compatibility
redis/memcached), and DB driver support in a staging environment before committing.config:cache) and route caching behave correctly with middleware parameters — a common source of "works locally, fails in prod."RateLimiter definitions on the same routes; document which layer owns which failure response.Sequencing
Maintenance
Support
Scaling
Failure modes
| Failure | Impact | Mitigation |
|---|---|---|
| Cache unavailable | Cooldowns silently stop enforcing | Explicit fail-open/fail-closed decision; alerting on store health |
| Redis eviction / flush | Windows reset early | Use DB storage for security-critical windows |
| Non-atomic check-set | Burst bypass under concurrency | Verify atomicity in spike; load test |
| DB row accumulation | Table bloat, slow lookups | Scheduled prune + indexes |
| Overlap with native throttle | Confusing/contradictory 429s | Single owner per route; document contract |
| Key collision / missing tenant scope | Cross-tenant enforcement errors | Mandate namespacing convention in ADR |
| Middleware misordering | Guard bypassed or 500s | Route-level tests in CI |
Ramp-up
TPM recommendation: proceed to a time-boxed spike, not a broad rollout. The package is architecturally well-fitted and cheap to integrate, but the adoption signal (38 stars, 0 dependents), single-publisher provenance, and anomalous release metadata make it a conditional dependency. Gate production use on verified atomicity, an explicit fail-mode decision, and a documented fork/exit path.
How can I help you explore Laravel packages today?