From 8f7c84a4568fa3ad54c128c7f3136e6acaa31a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 5 Jan 2021 14:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Pool/Connection.php | 1 + System/Pool/Redis.php | 41 +------------------------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index d6b7116e..50bd9508 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -238,6 +238,7 @@ class Connection extends Pool if (!empty($charset)) { $link->query('SET NAMES ' . $charset); } + $this->success('create db client has num ' . $this->size($coroutineName) . ', has create ' . $this->hasCreate[$coroutineName]); $this->success('create db client -> ' . $cds . ':' . env('workerId', 0) . ':' . Coroutine::getCid()); $this->incr($coroutineName); if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) { diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index e8adf5d3..2a9edb65 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -85,6 +85,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 db client has num ' . $this->size($coroutineName) . ', has create ' . $this->_create); $this->success('create redis client -> ' . $config['host'] . ':' . env('workerId', 0) . ':' . Coroutine::getCid()); if (!isset($config['read_timeout'])) { $config['read_timeout'] = 10; @@ -110,46 +111,6 @@ class Redis extends Pool } - /** - * @param array $config - * @param string $coroutineName - * @throws Exception - */ -// private function createConnect(array $config, string $coroutineName): void -// { -// try { -// if ($this->_create >= $this->max) { -// return; -// } -// $this->_create += 1; -// if (Context::hasContext('at_create_db')) { -// return; -// } -// Context::setContext('at_create_db', 1); -// $redis = new SRedis(); -// if (!$redis->connect($config['host'], (int)$config['port'], $config['timeout'])) { -// throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port'])); -// } -// 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 redis client -> ' . $config['host'] . ':' . $this->size($coroutineName)); -// if (!isset($config['read_timeout'])) { -// $config['read_timeout'] = 10; -// } -// $redis->select($config['databases']); -// $redis->setOption(SRedis::OPT_READ_TIMEOUT, $config['read_timeout']); -// $redis->setOption(SRedis::OPT_PREFIX, $config['prefix']); -// -// $this->push($coroutineName, $redis); -// } catch (\Throwable $exception) { -// $this->addError($exception->getMessage()); -// } finally { -// Context::deleteId('at_create_db'); -// } -// -// } - /** * @param array $config * @param bool $isMaster