改名
This commit is contained in:
@@ -235,7 +235,6 @@ class Connection extends Pool
|
|||||||
*/
|
*/
|
||||||
private function nowClient($coroutineName, $config)
|
private function nowClient($coroutineName, $config)
|
||||||
{
|
{
|
||||||
$this->success('create db client -> ' . $config['cds'] . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName));
|
|
||||||
$client = $this->createConnect($coroutineName, ...$this->parseConfig($config));
|
$client = $this->createConnect($coroutineName, ...$this->parseConfig($config));
|
||||||
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
|
||||||
$number > 0 && $client->beginTransaction();
|
$number > 0 && $client->beginTransaction();
|
||||||
@@ -372,6 +371,7 @@ class Connection extends Pool
|
|||||||
if (!empty($charset)) {
|
if (!empty($charset)) {
|
||||||
$link->query('SET NAMES ' . $charset);
|
$link->query('SET NAMES ' . $charset);
|
||||||
}
|
}
|
||||||
|
$this->success('create db client -> ' . $cds . ':' . $this->hasCreate[$coroutineName] . ':' . $this->size($coroutineName));
|
||||||
$this->incr($coroutineName);
|
$this->incr($coroutineName);
|
||||||
return $link;
|
return $link;
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ class Redis extends Pool
|
|||||||
if (Context::hasContext($coroutineName)) {
|
if (Context::hasContext($coroutineName)) {
|
||||||
return Context::getContext($coroutineName);
|
return Context::getContext($coroutineName);
|
||||||
} else if (!$this->hasItem($coroutineName)) {
|
} else if (!$this->hasItem($coroutineName)) {
|
||||||
$this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName));
|
return $this->saveClient($coroutineName, $this->createConnect($config, $coroutineName));
|
||||||
return $this->saveClient($coroutineName, $this->createConnect($config));
|
|
||||||
}
|
}
|
||||||
return $this->getByChannel($coroutineName, $config);
|
return $this->getByChannel($coroutineName, $config);
|
||||||
}
|
}
|
||||||
@@ -56,8 +55,7 @@ class Redis extends Pool
|
|||||||
public function getByChannel($coroutineName, $config)
|
public function getByChannel($coroutineName, $config)
|
||||||
{
|
{
|
||||||
if (!$this->hasItem($coroutineName)) {
|
if (!$this->hasItem($coroutineName)) {
|
||||||
$this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName));
|
return $this->saveClient($coroutineName, $this->createConnect($config, $coroutineName));
|
||||||
return $this->saveClient($coroutineName, $this->createConnect($config));
|
|
||||||
}
|
}
|
||||||
$clients = $this->get($coroutineName);
|
$clients = $this->get($coroutineName);
|
||||||
if ($clients[1] === null) {
|
if ($clients[1] === null) {
|
||||||
@@ -81,10 +79,11 @@ class Redis extends Pool
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $config
|
* @param array $config
|
||||||
|
* @param string $coroutineName
|
||||||
* @return SRedis
|
* @return SRedis
|
||||||
* @throws Exception
|
* @throws RedisConnectException
|
||||||
*/
|
*/
|
||||||
private function createConnect(array $config)
|
private function createConnect(array $config, string $coroutineName)
|
||||||
{
|
{
|
||||||
$redis = new SRedis();
|
$redis = new SRedis();
|
||||||
if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) {
|
if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) {
|
||||||
@@ -93,6 +92,7 @@ class Redis extends Pool
|
|||||||
if (empty($config['auth']) || !$redis->auth($config['auth'])) {
|
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']));
|
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'])) {
|
if (!isset($config['read_timeout'])) {
|
||||||
$config['read_timeout'] = 10;
|
$config['read_timeout'] = 10;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user