Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/mutex/SpinlockMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions tests/mutex/MemcachedMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions tests/mutex/PredisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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;
Expand All @@ -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())
Expand Down