File tree 1 file changed +2
-3
lines changed
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ final class RedisMutexService implements MutexService
38
38
public function __construct (Redis $ client , int $ lockLifetime = self ::DEFAULT_LOCK_LIFETIME )
39
39
{
40
40
$ this ->client = $ client ;
41
- $ this ->lockOptions = (new SetOptions ())->withTtl ($ lockLifetime );
41
+ $ this ->lockOptions = (new SetOptions ())->withTtl ($ lockLifetime )-> withoutOverwrite () ;
42
42
}
43
43
44
44
public function withLock (string $ id , callable $ code ): Promise
@@ -48,12 +48,11 @@ function () use ($id, $code): \Generator
48
48
{
49
49
try
50
50
{
51
- while (yield $ this ->client ->has ($ id ))
51
+ while (! yield $ this ->client ->set ($ id, ' lock ' , $ this -> lockOptions ))
52
52
{
53
53
yield delay (self ::LATENCY_TIMEOUT );
54
54
}
55
55
56
- yield $ this ->client ->set ($ id , 'lock ' , $ this ->lockOptions );
57
56
yield call ($ code );
58
57
}
59
58
finally
You can’t perform that action at this time.
0 commit comments