File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 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
3838    public  function  __construct (Redis   $ client , int  $ lockLifetime  = self ::DEFAULT_LOCK_LIFETIME )
3939    {
4040        $ this  ->client       = $ client ;
41-         $ this  ->lockOptions  = (new  SetOptions ())->withTtl ($ lockLifetime );
41+         $ this  ->lockOptions  = (new  SetOptions ())->withTtl ($ lockLifetime )-> withoutOverwrite () ;
4242    }
4343
4444    public  function  withLock (string  $ id , callable  $ code ): Promise 
@@ -48,12 +48,11 @@ function () use ($id, $code): \Generator
4848            {
4949                try 
5050                {
51-                     while  (yield  $ this  ->client ->has ($ id ))
51+                     while  (! yield  $ this  ->client ->set ($ id,  ' lock ' ,  $ this -> lockOptions ))
5252                    {
5353                        yield  delay (self ::LATENCY_TIMEOUT );
5454                    }
5555
56-                     yield  $ this  ->client ->set ($ id , 'lock ' , $ this  ->lockOptions );
5756                    yield  call ($ code );
5857                }
5958                finally 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments