ginnerpeace/laravel-redis-lock
A Laravel package that adds Redis-backed locks for coordinating concurrent work across processes and servers. A simple API lets you acquire, release, and manage locks with TTLs and blocking waits, helping prevent race conditions in queued jobs, artisan commands, and scheduled tasks.
Cache::lock() / WithoutOverlapping / ShouldBeUnique, (b) adopt a thin package like this one, or (c) hand-roll. This package only wins if it closes a concrete gap in (a). Default the roadmap to (a).Consider it when all of these hold:
Cache::lock() doesn't fit: blocking/retry ergonomics, TTL renewal for long tasks, reentrancy, or a model-bound helper. "It's simpler" is not a reason; core is already one line.Look elsewhere when:
Cache::lock(), WithoutOverlapping middleware, and ShouldBeUnique jobs already cover the common cases with zero new dependencies.Adoption gate (PM should ask engineering to confirm): acquisition via SET NX with an owner token and TTL; release via Lua compare-and-delete rather than a naive DEL; sane behavior on Redis Cluster (single-key, no cross-slot); Laravel version support matrix; test coverage; license.
To executives: "We have a class of bugs where the same work runs twice — duplicate charges, double-sent emails, oversold inventory. The fix is a lock, and we can get one nearly for free because Laravel and Redis already give us the primitive. My recommendation is not to adopt this specific package: it's a 15-star, single-maintainer library that duplicates what the framework ships. We standardize on the built-in mechanism, spend roughly a day, and revisit only if we hit a real limitation. Nothing here is a platform bet; it's reversible in a day and adds no new infrastructure."
To engineering: "Treat this as a 30-minute spike, not a procurement. Compare Cache::lock() semantics against this package's API — if you can't name a gap in one sentence, close the ticket. If we do adopt it, wrap it behind our own interface, log acquisition failures and hold times so we can see contention, and make owner-token release non-negotiable. And be explicit in the design doc about what a lost lock costs us: if the answer is 'a duplicate charge,' this package is the wrong tool regardless of how clean the API is."
How can I help you explore Laravel packages today?