Skip to content

Commit 7459808

Browse files
authored
More lib specific lock prefix (#59)
1 parent 7cb08aa commit 7459808

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/mutex/SpinlockMutex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
abstract class SpinlockMutex extends LockMutex
1818
{
1919
/** The prefix for the lock key. */
20-
private const PREFIX = 'lock_';
20+
private const PREFIX = 'php-malkusch-lock:';
2121

2222
/** @var float The timeout in seconds a lock may live */
2323
private $timeout;

tests/mutex/MemcachedMutexTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testFailAcquireLock(): void
3939

4040
$this->memcached->expects(self::atLeastOnce())
4141
->method('add')
42-
->with('lock_test', true, 2)
42+
->with('php-malkusch-lock:test', true, 2)
4343
->willReturn(false);
4444

4545
$this->mutex->synchronized(static function (): void {
@@ -56,12 +56,12 @@ public function testFailReleasingLock(): void
5656

5757
$this->memcached->expects(self::once())
5858
->method('add')
59-
->with('lock_test', true, 2)
59+
->with('php-malkusch-lock:test', true, 2)
6060
->willReturn(true);
6161

6262
$this->memcached->expects(self::once())
6363
->method('delete')
64-
->with('lock_test')
64+
->with('php-malkusch-lock:test')
6565
->willReturn(false);
6666

6767
$this->mutex->synchronized(static function (): void {});

tests/mutex/PredisMutexTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testAddFailsToSetKey(): void
5050
{
5151
$this->client->expects(self::atLeastOnce())
5252
->method('set')
53-
->with('lock_test', self::isType('string'), 'PX', 3500, 'NX')
53+
->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX')
5454
->willReturn(null);
5555

5656
$this->logger->expects(self::never())
@@ -72,7 +72,7 @@ public function testAddErrors(): void
7272
{
7373
$this->client->expects(self::atLeastOnce())
7474
->method('set')
75-
->with('lock_test', self::isType('string'), 'PX', 3500, 'NX')
75+
->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX')
7676
->willThrowException($this->createMock(PredisException::class));
7777

7878
$this->logger->expects(self::once())
@@ -92,12 +92,12 @@ public function testWorksNormally(): void
9292
{
9393
$this->client->expects(self::atLeastOnce())
9494
->method('set')
95-
->with('lock_test', self::isType('string'), 'PX', 3500, 'NX')
95+
->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX')
9696
->willReturnSelf();
9797

9898
$this->client->expects(self::once())
9999
->method('eval')
100-
->with(self::anything(), 1, 'lock_test', self::isType('string'))
100+
->with(self::anything(), 1, 'php-malkusch-lock:test', self::isType('string'))
101101
->willReturn(true);
102102

103103
$executed = false;
@@ -116,12 +116,12 @@ public function testEvalScriptFails(): void
116116
{
117117
$this->client->expects(self::atLeastOnce())
118118
->method('set')
119-
->with('lock_test', self::isType('string'), 'PX', 3500, 'NX')
119+
->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX')
120120
->willReturnSelf();
121121

122122
$this->client->expects(self::once())
123123
->method('eval')
124-
->with(self::anything(), 1, 'lock_test', self::isType('string'))
124+
->with(self::anything(), 1, 'php-malkusch-lock:test', self::isType('string'))
125125
->willThrowException($this->createMock(PredisException::class));
126126

127127
$this->logger->expects(self::once())

0 commit comments

Comments
 (0)