src/Controller/Plugin/Mutex.php
public function lock($key)
    {
        $this->init($key);

        if (!flock($this->files[$key], LOCK_EX)) { //failed
            error_log('ExclusiveLock::acquire_lock FAILED to acquire lock [' . $key . ']');
            return false;
        } else {
            ftruncate($this->files[$key], 0); // truncate file
            // write something to just help debugging
            fwrite($this->files[$key], 'Locked' . PHP_EOL);
            fflush($this->files[$key]);

            $this->owns[$key] = true;
            return true;
        }
    }
public function lock($key)
    {
        $this->init($key);

        if (!flock($this->files[$key], LOCK_EX)) { //failed
            error_log('ExclusiveLock::acquire_lock FAILED to acquire lock [' . $key . ']');
            return false;
        } else {
            ftruncate($this->files[$key], 0); // truncate file
            // write something to just help debugging
            fwrite($this->files[$key], 'Locked' . PHP_EOL);
            fflush($this->files[$key]);

            $this->owns[$key] = true;
            return true;
        }
    }
Lock resource
@param $key
@return bool