public function lock () {
        if (!$this->beforeLock ()) {
            return false;
        }
        $redis = $this->getConnection ()->getClient ();
        if (!$redis->setnx ($this->name , $this->getExpiresAt (true))) {
            // see if this mutex has expired

            $value = $redis->get ($this->name);
            if ($value > microtime (true)) {
                return false;
            }
        }
        $this->afterLock ();
        return true;
    }
public function lock () {
        if (!$this->beforeLock ()) {
            return false;
        }
        $redis = $this->getConnection ()->getClient ();
        if (!$redis->setnx ($this->name , $this->getExpiresAt (true))) {
            // see if this mutex has expired

            $value = $redis->get ($this->name);
            if ($value > microtime (true)) {
                return false;
            }
        }
        $this->afterLock ();
        return true;
    }
public function lock ( ) { if ( ! $ this -> beforeLock ( ) ) { return false ; } $ redis = $ this -> getConnection ( ) -> getClient ( ) ; if ( ! $ redis -> setnx ( $ this -> name , $ this -> getExpiresAt ( true ) ) ) { // see if this mutex has expired $ value = $ redis -> get ( $ this -> name ) ; if ( $ value > microtime ( true ) ) { return false ; } } $ this -> afterLock ( ) ; return true ; }
Attempts to lock the mutex, returns true if successful or false if the mutex is locked by another process.
@return boolean whether the lock was successful or not
Attempts to lock the mutex returns true if successful or false if the mutex is locked by another process .