Update (v1.1.0): Based on some great community feedback, Laravel Cooldown now includes native atomic concurrency protection.
The package now uses an atomic check → lock → execute → set flow to prevent duplicate execution during concurrent requests while still preserving its original success-only cooldown behavior. In other words, cooldowns are only created after successful execution (2xx/3xx), but simultaneous requests for the same action are safely blocked with a temporary in-flight lock.
This release also introduces a new high-level block() API:
Cooldown::for('send_otp', $user)->block(function () use ($otpService, $user) {
$otpService->send($user->phone);
}, duration: 120);
This makes workflows such as OTP delivery, payment processing, report generation, and other concurrency-sensitive operations safe out of the box, without requiring additional locking boilerplate.
Thanks to everyone who shared feedback and questions,it directly helped improve both the implementation and the documentation.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.