From 66ccdccbb3b9a2cabdeba077f6aa1759dd3fbcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 5 Dec 2024 23:54:01 +0100 Subject: [PATCH] Revert "More lib specific lock prefix (#59)" --- src/mutex/SpinlockMutex.php | 2 +- tests/mutex/MemcachedMutexTest.php | 6 +++--- tests/mutex/PredisMutexTest.php | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mutex/SpinlockMutex.php b/src/mutex/SpinlockMutex.php index e177f2b9..73418b8f 100644 --- a/src/mutex/SpinlockMutex.php +++ b/src/mutex/SpinlockMutex.php @@ -17,7 +17,7 @@ abstract class SpinlockMutex extends LockMutex { /** The prefix for the lock key. */ - private const PREFIX = 'php-malkusch-lock:'; + private const PREFIX = 'lock_'; /** @var float The timeout in seconds a lock may live */ private $timeout; diff --git a/tests/mutex/MemcachedMutexTest.php b/tests/mutex/MemcachedMutexTest.php index 9fbb7dd8..6aa2fb8c 100644 --- a/tests/mutex/MemcachedMutexTest.php +++ b/tests/mutex/MemcachedMutexTest.php @@ -43,7 +43,7 @@ public function testFailAcquireLock(): void $this->memcached->expects(self::atLeastOnce()) ->method('add') - ->with('php-malkusch-lock:test', true, 2) + ->with('lock_test', true, 2) ->willReturn(false); $this->mutex->synchronized(static function (): void { @@ -60,12 +60,12 @@ public function testFailReleasingLock(): void $this->memcached->expects(self::once()) ->method('add') - ->with('php-malkusch-lock:test', true, 2) + ->with('lock_test', true, 2) ->willReturn(true); $this->memcached->expects(self::once()) ->method('delete') - ->with('php-malkusch-lock:test') + ->with('lock_test') ->willReturn(false); $this->mutex->synchronized(static function (): void {}); diff --git a/tests/mutex/PredisMutexTest.php b/tests/mutex/PredisMutexTest.php index c39e43c3..22f90ae7 100644 --- a/tests/mutex/PredisMutexTest.php +++ b/tests/mutex/PredisMutexTest.php @@ -62,7 +62,7 @@ public function testAddFailsToSetKey(): void { $this->client->expects(self::atLeastOnce()) ->method('set') - ->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX') + ->with('lock_test', self::isType('string'), 'PX', 3500, 'NX') ->willReturn(null); $this->logger->expects(self::never()) @@ -84,7 +84,7 @@ public function testAddErrors(): void { $this->client->expects(self::atLeastOnce()) ->method('set') - ->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX') + ->with('lock_test', self::isType('string'), 'PX', 3500, 'NX') ->willThrowException($this->createMock(PredisException::class)); $this->logger->expects(self::once()) @@ -104,12 +104,12 @@ public function testWorksNormally(): void { $this->client->expects(self::atLeastOnce()) ->method('set') - ->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX') + ->with('lock_test', self::isType('string'), 'PX', 3500, 'NX') ->willReturnSelf(); $this->client->expects(self::once()) ->method('eval') - ->with(self::anything(), 1, 'php-malkusch-lock:test', self::isType('string')) + ->with(self::anything(), 1, 'lock_test', self::isType('string')) ->willReturn(true); $executed = false; @@ -128,12 +128,12 @@ public function testEvalScriptFails(): void { $this->client->expects(self::atLeastOnce()) ->method('set') - ->with('php-malkusch-lock:test', self::isType('string'), 'PX', 3500, 'NX') + ->with('lock_test', self::isType('string'), 'PX', 3500, 'NX') ->willReturnSelf(); $this->client->expects(self::once()) ->method('eval') - ->with(self::anything(), 1, 'php-malkusch-lock:test', self::isType('string')) + ->with(self::anything(), 1, 'lock_test', self::isType('string')) ->willThrowException($this->createMock(PredisException::class)); $this->logger->expects(self::once())