public function lock(Request $request)
    {
        $key = $this->getCacheKey($request);

        if (!isset($this->locks[$key])) {
            $path = $this->getPath($key);
            if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
                return $path;
            }
            $h = fopen($path, 'cb');
            if (!flock($h, LOCK_EX | LOCK_NB)) {
                fclose($h);

                return $path;
            }

            $this->locks[$key] = $h;
        }

        return true;
    }
public function lock(Request $request)
    {
        $key = $this->getCacheKey($request);

        if (!isset($this->locks[$key])) {
            $path = $this->getPath($key);
            if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
                return $path;
            }
            $h = fopen($path, 'cb');
            if (!flock($h, LOCK_EX | LOCK_NB)) {
                fclose($h);

                return $path;
            }

            $this->locks[$key] = $h;
        }

        return true;
    }
public function lock ( Request $ request ) { $ key = $ this -> getCacheKey ( $ request ) ; if ( ! isset ( $ this -> locks [ $ key ] ) ) { $ path = $ this -> getPath ( $ key ) ; if ( ! file_exists ( \ dirname ( $ path ) ) && false === @ mkdir ( \ dirname ( $ path ) , 0777 , true ) && ! is_dir ( \ dirname ( $ path ) ) ) { return $ path ; } $ h = fopen ( $ path , 'cb' ) ; if ( ! flock ( $ h , LOCK_EX | LOCK_NB ) ) { fclose ( $ h ) ; return $ path ; } $ this -> locks [ $ key ] = $ h ; } return true ; }
Tries to lock the cache for a given Request, without blocking.

@return bool|string true if the lock is acquired, the path to the current lock otherwise
Tries to lock the cache for a given Request without blocking .