77use malkusch \lock \exception \ExecutionOutsideLockException ;
88use malkusch \lock \exception \LockAcquireException ;
99use malkusch \lock \exception \LockReleaseException ;
10+ use malkusch \lock \util \LockUtil ;
1011use malkusch \lock \util \Loop ;
1112
1213/**
1617 */
1718abstract class SpinlockMutex extends LockMutex
1819{
19- /** The prefix for the lock key. */
20- private const PREFIX = 'php-malkusch-lock: ' ;
21-
2220 /** @var float The timeout in seconds a lock may live */
2321 private $ timeout ;
2422
@@ -34,15 +32,15 @@ abstract class SpinlockMutex extends LockMutex
3432 /**
3533 * Sets the timeout.
3634 *
37- * @param float $timeout The time in seconds a lock expires
35+ * @param float $timeout The timeout in seconds a lock expires
3836 *
3937 * @throws \LengthException The timeout must be greater than 0
4038 */
4139 public function __construct (string $ name , float $ timeout = 3 )
4240 {
4341 $ this ->timeout = $ timeout ;
4442 $ this ->loop = new Loop ($ this ->timeout );
45- $ this ->key = self :: PREFIX . $ name ;
43+ $ this ->key = LockUtil:: getInstance ()-> getKeyPrefix () . ' : ' . $ name ;
4644 }
4745
4846 #[\Override]
@@ -52,7 +50,7 @@ protected function lock(): void
5250 $ this ->acquired = microtime (true );
5351
5452 /*
55- * The expiration time for the lock is increased by one second
53+ * The expiration timeout for the lock is increased by one second
5654 * to ensure that we delete only our keys. This will prevent the
5755 * case that this key expires before the timeout, and another process
5856 * acquires successfully the same key which would then be deleted
0 commit comments