/**
* 分佈式鎖
*/
public function actionSetexnx()
{
$lockey = 'lock:codehole';
//分佈式鎖
$redisHelper = new RedisHelper();
//獲取鎖狀態
/** @var \Predis\Response\Status $locker */
$locker = $redisHelper->getDisLock($this->redisClient, $lockey, 'aaa', 10);
if ($locker) {
$a = $this->redisClient->get('lockdata');
if ($a >= 10) {
return;
}
var_dump($a = $this->redisClient->incrby('lockdata', 1));
var_dump($redisHelper->removeDisLock($this->redisClient, $lockey));
var_dump($this->redisClient->exists($lockey));
} else {
var_dump("正在處理中");
}
exit();
}複製代碼