Skip to content

Commit 483ca5a

Browse files
committed
improve distributed dummy key
1 parent 70cdeb9 commit 483ca5a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Mutex/DistributedMutex.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class DistributedMutex extends AbstractSpinlockWithTokenMutex implements LoggerA
3434
public function __construct(array $mutexes, float $acquireTimeout = 3, float $expireTimeout = \INF)
3535
{
3636
parent::__construct('', $acquireTimeout, $expireTimeout);
37+
\Closure::bind(function () {
38+
$this->key = 'distributed';
39+
}, $this, AbstractSpinlockMutex::class)();
3740

3841
$this->mutexes = $mutexes;
3942
$this->logger = new NullLogger();

tests/Mutex/DistributedMutexTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function testAcquireMutexLogger(): void
331331

332332
$mutex->expects(self::exactly(3))
333333
->method('acquireMutex')
334-
->with(self::isInstanceOf(AbstractSpinlockMutex::class), 'php-malkusch-lock:', 1.0, \INF)
334+
->with(self::isInstanceOf(AbstractSpinlockMutex::class), 'distributed', 1.0, \INF)
335335
->willThrowException($this->createMock(/* PredisException::class */ LockAcquireException::class));
336336

337337
$logger->expects(self::exactly(3))
@@ -357,7 +357,7 @@ public function testReleaseMutexLogger(): void
357357

358358
$mutex->expects(self::exactly(3))
359359
->method('releaseMutex')
360-
->with(self::isInstanceOf(AbstractSpinlockMutex::class), 'php-malkusch-lock:', \INF)
360+
->with(self::isInstanceOf(AbstractSpinlockMutex::class), 'distributed', \INF)
361361
->willThrowException($this->createMock(/* PredisException::class */ LockReleaseException::class));
362362

363363
$logger->expects(self::exactly(3))

0 commit comments

Comments
 (0)