diff --git a/classes/mutex/SpinlockMutex.php b/classes/mutex/SpinlockMutex.php index be51939e..6e156514 100644 --- a/classes/mutex/SpinlockMutex.php +++ b/classes/mutex/SpinlockMutex.php @@ -22,7 +22,7 @@ abstract class SpinlockMutex extends LockMutex /** * The prefix for the lock key. */ - private const PREFIX = 'lock_'; + private const PREFIX = 'php_malkusch_lock:'; /** * @var int The timeout in seconds a lock may live. diff --git a/tests/mutex/MemcachedMutexTest.php b/tests/mutex/MemcachedMutexTest.php index b18e473f..4091942e 100644 --- a/tests/mutex/MemcachedMutexTest.php +++ b/tests/mutex/MemcachedMutexTest.php @@ -45,7 +45,7 @@ public function testFailAcquireLock() $this->memcached->expects($this->atLeastOnce()) ->method('add') - ->with('lock_test', true, 2) + ->with('php_malkusch_lock:test', true, 2) ->willReturn(false); $this->mutex->synchronized(function (): void { @@ -62,12 +62,12 @@ public function testFailReleasingLock() $this->memcached->expects($this->once()) ->method('add') - ->with('lock_test', true, 2) + ->with('php_malkusch_lock:test', true, 2) ->willReturn(true); $this->memcached->expects($this->once()) ->method('delete') - ->with('lock_test') + ->with('php_malkusch_lock:test') ->willReturn(false); $this->mutex->synchronized(function (): void { diff --git a/tests/mutex/PredisMutexTest.php b/tests/mutex/PredisMutexTest.php index 81a53f0f..13bcf6e7 100644 --- a/tests/mutex/PredisMutexTest.php +++ b/tests/mutex/PredisMutexTest.php @@ -56,7 +56,7 @@ public function testAddFailsToSetKey() { $this->client->expects($this->atLeastOnce()) ->method('set') - ->with('lock_test', $this->isType('string'), 'EX', 4, 'NX') + ->with('php_malkusch_lock:test', $this->isType('string'), 'EX', 4, 'NX') ->willReturn(null); $this->logger->expects($this->never()) @@ -78,7 +78,7 @@ public function testAddErrors() { $this->client->expects($this->atLeastOnce()) ->method('set') - ->with('lock_test', $this->isType('string'), 'EX', 4, 'NX') + ->with('php_malkusch_lock:test', $this->isType('string'), 'EX', 4, 'NX') ->willThrowException($this->createMock(PredisException::class)); $this->logger->expects($this->once()) @@ -98,12 +98,12 @@ public function testWorksNormally() { $this->client->expects($this->atLeastOnce()) ->method('set') - ->with('lock_test', $this->isType('string'), 'EX', 4, 'NX') + ->with('php_malkusch_lock:test', $this->isType('string'), 'EX', 4, 'NX') ->willReturnSelf(); $this->client->expects($this->once()) ->method('eval') - ->with($this->anything(), 1, 'lock_test', $this->isType('string')) + ->with($this->anything(), 1, 'php_malkusch_lock:test', $this->isType('string')) ->willReturn(true); $executed = false; @@ -122,12 +122,12 @@ public function testEvalScriptFails() { $this->client->expects($this->atLeastOnce()) ->method('set') - ->with('lock_test', $this->isType('string'), 'EX', 4, 'NX') + ->with('php_malkusch_lock:test', $this->isType('string'), 'EX', 4, 'NX') ->willReturnSelf(); $this->client->expects($this->once()) ->method('eval') - ->with($this->anything(), 1, 'lock_test', $this->isType('string')) + ->with($this->anything(), 1, 'php_malkusch_lock:test', $this->isType('string')) ->willThrowException($this->createMock(PredisException::class)); $this->logger->expects($this->once())