...
|
...
|
@@ -20,9 +20,21 @@ class RedisPool { |
|
|
*/
|
|
|
private $client;
|
|
|
|
|
|
/**
|
|
|
* @var
|
|
|
*/
|
|
|
private $cid;
|
|
|
|
|
|
/**
|
|
|
* 最后执行的时间
|
|
|
* @var int
|
|
|
*/
|
|
|
public $lastTimer;
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
public function __construct($cid)
|
|
|
{
|
|
|
$this->cid = $cid;
|
|
|
$this->conn();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -32,9 +44,10 @@ class RedisPool { |
|
|
* @time 2023/4/12 15:10
|
|
|
*/
|
|
|
private function conn(){
|
|
|
$this->lastTimer = time();
|
|
|
$this->client = new \Redis();
|
|
|
|
|
|
$this->client->pconnect(REDIS_HOST,REDIS_PORT,5);
|
|
|
$this->client->pconnect(REDIS_HOST,REDIS_PORT,1);
|
|
|
// 密码
|
|
|
REDIS_PASSWORD && $this->client->auth(REDIS_PASSWORD);
|
|
|
// 用库4
|
...
|
...
|
@@ -251,6 +264,7 @@ class RedisPool { |
|
|
}catch (\Throwable $e){
|
|
|
$this->conn();
|
|
|
}
|
|
|
$this->lastTimer = time();
|
|
|
return $this->client;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -269,8 +283,9 @@ class RedisPool { |
|
|
* @time 2023/2/13 9:38
|
|
|
*/
|
|
|
public static function instance($cid){
|
|
|
|
|
|
if(empty(static::$instance[$cid])){
|
|
|
static::$instance[$cid] = new \Lib\RedisPool();
|
|
|
static::$instance[$cid] = new \Lib\RedisPool($cid);
|
|
|
}
|
|
|
|
|
|
return static::$instance[$cid];
|
...
|
...
|
@@ -291,7 +306,9 @@ class RedisPool { |
|
|
|
|
|
}
|
|
|
|
|
|
unset(static::$instance[$this->cid]);
|
|
|
$this->client = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|