swoole-framwork/core/lib/PHPRedisPool.php
2024-05-22 15:50:08 +08:00

27 lines
733 B
PHP

<?php
namespace Core\lib;
/**
* Class PHPRedisPool
*/
class PHPRedisPool extends RedisPool{
public function __construct(int $min = 5, int $max = 10)
{
global $GLOBAL_CONFIGS;
$poolconfig=$GLOBAL_CONFIGS["redispool"]["default"];
parent::__construct($poolconfig['min'], $poolconfig['max'],$poolconfig['idleTime']);
}
protected function newRedis()
{
global $GLOBAL_CONFIGS;
$default=$GLOBAL_CONFIGS["redis"]["default"];
$redis=new \Redis();
$redis->connect($default["host"],$default["port"]);
if($default["auth"]!=""){
$redis->auth($default["auth"]);
}
$redis->select($default['db'] ?? 0);
return $redis;
}
}