malkusch/lock
Mutex library for exclusive code execution.
3.1.1
10M downloads/mo
#1794 most downloaded on Packagist
php-lock/lock
What this package is like to depend on
Last release 6 months ago
19 Feb 2026
Ships unpredictably
gaps range from 9 days to 2.6 years
Some releases are documented
notes for 7 of 20 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
20 releases · first in 2015
1 release in the last 12 months
see the full history below
Release timeline
20 releases · Jul 2015 to Feb 2026Releases
latest 20-
3.1.119 Feb 2026Release notes
Open source →Other changes
- Add PHP 8.5 support (#83)
Full Changelog: 3.1.0...3.1.1
Upgrading notes
For upgrading from 2.x version see 3.0.0 release notes.
-
3.1.028 Jul 2025Release notes
Open source →Other changes
- Add acquire timeout support to PostgreSQLMutex (#80)
Full Changelog: 3.0.2...3.1.0
Upgrading notes
For upgrading from 2.x version see 3.0.0 release notes.
-
3.0.217 May 2025Release notes
Open source →Other changes
- Make AbstractLockMutex and Loop classes non-internal (#79)
Full changelog: 3.0.1...3.0.2
Upgrading notes
For upgrading from 2.x version see 3.0.0 release notes.
-
3.0.117 Dec 2024Release notes
Open source →Other changes
- Add PHP 8.4 support (#58)
Full changelog: 3.0.0...3.0.1
Upgrading notes
For upgrading from 2.x version see 3.0.0 release notes.
-
3.0.015 Dec 2024Release notes
Open source →Major features - renamed namespace
- Rename namespace to PascalCase (#65)
Rename all FQCN uses from camelCase to PascalCase like
malkusch\lock\mutex\MutextoMalkusch\Lock\Mutex\Mutex.Major features - renamed namespace
- Merge Redis mutex implementations into single RedisMutex class (#69)
- Introduce DistributedMutex class (#75)
In 2.x version, there were two
PHPRedisMutexandPredisMutexclasses. They were almost a duplicate of each other and both have implemented RedLock distributed lock when more than 1 Redis client instance was passed to the constructor.Newly, in 3.x version, both class were unified into one
RedisMutexclass supporting both PHP redis and Predis clients. In addition, the constructor newly accepts only single Redis client instance.When distributed lock is wanted, use new
DistributedMutexclass which newly accepts anyAbstractSpinlockMutexclass which is currently implemented byRedisMutexandMemcachedMutex. This change allows you to create distributed lock across different backends.Major features - other
- Introduce AbstractSpinlockWithTokenMutex class (#72)
- Add fail callback support in DoubleCheckedLocking::then() method (#76)
Newly we strictly distinguish between:
- "acquire timeout" (timeout before the library give up trying to acquire a lock for your code)
- and "expire timeout" (timeout after the lock expires on the, possibly remote, store).Breaking changes
- Unify lock/unlock methods visibility (#62)
- Prefix MySQL and PostgreSQL mutex name (#63, #64)
- Remove CASMutex class (#67)
- Improve abstract mutex classes naming (#68)
- Rename TimeoutException to LockAcquireTimeoutException (#70)
- Remove TransactionalMutex class (#73)
- Rename NoMutex class to NullMutex (#74)
Other changes
- Internal
LockUtilclass was added to deduplicate the code (70fd6d9) - Fix float to int casting and improve timeout names (#71)
- Improve distributed locking (#77)
- Fix pcntl_signal() restore when pcntl_alarm() is set (4fe9681)
Full changelog: 2.3.0...3.0.0
-
2.3.005 Dec 2024Release notes
Open source →Major features
- Add support for fractional seconds timeout (#55)
Other changes
- Drop PHP 7.2 and PHP 7.3 support (b10b0a0)
- Emit exceptions without "." at the end (515250e)
- Improve RedisMutex token randomness (a98afa2)
Full changelog: 2.2.1...2.3.0
-
v2.2.126 Apr 2022 -
1.0.005 Aug 2016Nothing published for this version
-
0.2.127 Jul 2015Nothing published for this version
-
v2.207 Mar 2021Nothing published for this version
-
v2.112 Dec 2018Nothing published for this version
-
v2.008 Nov 2018Nothing published for this version
-
v1.407 Jul 2018Nothing published for this version
-
v1.326 May 2018Nothing published for this version
-
v1.221 May 2018Nothing published for this version
-
v1.115 Apr 2018Nothing published for this version
-
0.411 Aug 2015Nothing published for this version
-
0.331 Jul 2015Nothing published for this version
-
0.224 Jul 2015Nothing published for this version
-
0.112 Jul 2015Nothing published for this version