This commit is contained in:
2021-01-05 18:30:58 +08:00
parent f1fd58f794
commit 6d3de65dbb
2 changed files with 27 additions and 2 deletions
+13 -1
View File
@@ -77,6 +77,7 @@ class Redis extends Pool
*/
private function newClient($config, $coroutineName): \Redis|null
{
$this->printClients($config['cds'], $coroutineName, true);
return $this->createConnect([$config, $coroutineName], $coroutineName, function ($config, $coroutineName) {
$redis = new SRedis();
if (!$redis->connect($config['host'], (int)$config['port'], $config['timeout'])) {
@@ -85,7 +86,7 @@ class Redis extends Pool
if (empty($config['auth']) || !$redis->auth($config['auth'])) {
throw new RedisConnectException(sprintf('Redis Error: %s, Host %s, Auth %s', $redis->getLastError(), $config['host'], $config['auth']));
}
$this->success('create client[address: ' . $config['host'] . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ', has create: ' . $this->_create . ']');
$this->printClients($config['host'], $coroutineName);
if (!isset($config['read_timeout'])) {
$config['read_timeout'] = 10;
}
@@ -98,6 +99,17 @@ class Redis extends Pool
}
/**
* @param $cds
* @param $coroutineName
* @param false $isBefore
*/
public function printClients($cds, $coroutineName, $isBefore = false)
{
$this->success(($isBefore ? 'before ' : '') . 'create client[address: ' . $cds . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ', has create: ' . $this->hasCreate[$coroutineName] . ']');
}
/**
* @param $coroutineName
* @param $client