PHP code example of php-comp / lock
1. Go to this page and download the library: Download php-comp/lock library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-comp / lock example snippets
use PhpComp\Lock\Lock;
$locker = new Lock([
'driver' => '', // allow: File Database Memcache Semaphore
'tmpDir' => '/tmp', // tmp path, if use FileLock
]);
$key = 'op1';
if ($locker->lock($key)) {
// do something ...
$locker->unlock($key);
}
json
{
"hp-comp/lock": "dev-master"
}
}
bash
git clone https://git.oschina.net/inhere/php-lock.git // git@osc
git clone https://github.com/inhere/php-lock.git // github