Skip to content

Tags: utopia-php/lock

Tags

0.2.0

Toggle 0.2.0's commit message

Verified

This commit was signed with the committer’s verified signature.
abnegate Jake Barnby
refactor!: flatten namespaces — Utopia\Lock\Lock\* → Utopia\Lock\*

0.1.0

Toggle 0.1.0's commit message

Verified

This commit was signed with the committer’s verified signature.
abnegate Jake Barnby
feat: initial release with Mutex, Semaphore, File and Distributed locks

Four lock primitives behind a single `Utopia\Lock\Lock` interface:

- Mutex and Semaphore built on Swoole\Coroutine\Channel.
- File lock using flock(), cooperates with Swoole runtime hooks.
- Distributed lock using Redis SET NX EX with Lua-atomic release.

Port of the internal cloud Redis distributed lock, rewritten around a
fractional-second deadline so short timeouts are actually honoured
instead of blocking for 10s per retry.

`withLock()` always releases, even on exception, and throws
`Utopia\Lock\Exception\Contention` on acquire timeout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>