Laravel Cooldown is a package that enforces per-action, per-owner waiting periods in Laravel applications. Unlike the built-in RateLimiter which counts requests within a window, Cooldown tracks whether a specific named action for a specific owner is still within its waiting period. Key features include a fluent API for setting/checking/clearing cooldowns, an Eloquent HasCooldowns trait, route middleware, atomic locking via block() to prevent race conditions, a CooldownInfo object with human-readable remaining time, and support for both cache and database storage backends. The database backend is useful for critical actions like billing where cache flushes could remove locks. Requires PHP 8.2 and supports Laravel 11, 12, and 13.

4m read timeFrom laravel-news.com
Post cover image
Table of contents
# Main features# The Fluent API# Atomic Blocking# Cooldowns on Eloquent Models# Route Middleware# Storage Backends# Installation
95.4K Impressions1 Comment