Skip to content

Commit

Permalink
Revert "More lib specific lock prefix (#59)"
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 5, 2024
1 parent 3fd576b commit 66ccdcc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/mutex/SpinlockMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/mutex/MemcachedMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {});
Expand Down
12 changes: 6 additions & 6 deletions tests/mutex/PredisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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;
Expand All @@ -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())
Expand Down

0 comments on commit 66ccdcc

Please sign in to comment.