初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
declare (strict_types=1);
namespace app\common\lock;
use Predis\Client;
/**
* 订单服务类
* Class RedisLock
* @package app\common\lock
*/
class RedisLock
{
protected $redis;
protected $lockKey;
protected $timeout;
public function __construct($lockKey, $timeout = 30) {
$this->redis = new Client(config('redis'));
$this->lockKey = $lockKey;
$this->timeout = $timeout;
}
public function acquireLock() {
$result = $this->redis->set($this->lockKey, 'locked', 'NX', 'EX', $this->timeout);
return $result == 'OK';
}
public function releaseLock() {
$this->redis->del($this->lockKey);
}
}