PHP code example of kaadon / lock
1. Go to this page and download the library: Download kaadon/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/ */
kaadon / lock example snippets
// 文件
$fp = fopen('1.txt', 'w+');
$lock = new \Yurun\Until\Lock\File('我是锁名称', $fp);
$lock->lock();
// 做一些事情
$lock->unlock();
fclose($fp);
// redis、memcached同理
$redis = new \Redis;
$redis->connect($host, $port, $timeout);
$lock = new \Yurun\Until\Lock\Redis('我是锁名称', $$redis);
$lock->lock();
// 做一些事情
$lock->unlock();
redis->close();