This commit is contained in:
as2252258@163.com
2021-04-23 03:41:12 +08:00
parent 1edd8c5429
commit 176d6256d7
3 changed files with 40 additions and 18 deletions
+12
View File
@@ -169,6 +169,18 @@ abstract class Pool extends Component
} }
/**
* @param $cds
* @param $coroutineName
* @param false $isBefore
* @throws Exception
*/
public function releaseClients($cds, $coroutineName)
{
$this->warning('release client[address: ' . $cds . ', ' . env('worker', 0) . ', coroutine: ' . Coroutine::getCid() . ', has num: ' . $this->size($coroutineName) . ']');
}
abstract public function createClient(string $name, mixed $config): mixed; abstract public function createClient(string $name, mixed $config): mixed;
+4
View File
@@ -195,6 +195,8 @@ class Connection extends Pool
return; return;
} }
$this->releaseClients('rds', $coroutineName);
/** @var PDO $client */ /** @var PDO $client */
$client = Context::getContext($coroutineName); $client = Context::getContext($coroutineName);
if ($client->inTransaction()) { if ($client->inTransaction()) {
@@ -222,6 +224,8 @@ class Connection extends Pool
*/ */
public function connection_clear() public function connection_clear()
{ {
$this->releaseClients('rds', 'rds');
$this->flush(0); $this->flush(0);
} }
+6
View File
@@ -89,6 +89,9 @@ class Redis extends Pool
if (!Context::hasContext($coroutineName)) { if (!Context::hasContext($coroutineName)) {
return; return;
} }
$this->releaseClients($config['host'], $coroutineName);
$this->push($coroutineName, Context::getContext($coroutineName)); $this->push($coroutineName, Context::getContext($coroutineName));
$this->remove($coroutineName); $this->remove($coroutineName);
$this->lastTime = time(); $this->lastTime = time();
@@ -108,6 +111,9 @@ class Redis extends Pool
$this->remove($coroutineName); $this->remove($coroutineName);
} }
$this->releaseClients($config['host'], $coroutineName);
$this->clean($coroutineName); $this->clean($coroutineName);
} }