PHP code example of tinywan / webman-lock
1. Go to this page and download the library: Download tinywan/webman-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/ */
tinywan / webman-lock example snippets
// 锁名称
$lockName = md5((string) time());
// 锁标识
$lockId = \Tinywan\Lock\RedisLock::acquire($lockName);
if (!$lockId) {
return '未获得锁标识,请稍后再试';
}
// 业务处理
// 释放锁
\Tinywan\Lock\RedisLock::release($lockName, $lockId);