This commit is contained in:
2021-09-07 14:47:44 +08:00
parent 8844131a0b
commit 72578e46b5
+5 -4
View File
@@ -122,8 +122,7 @@ class Pool extends Component
{
$channel = $this->getChannel($name);
if (!$channel->isEmpty()) {
$connection = $channel->pop();
defer(fn() => $this->maxIdleQuantity($channel));
$connection = $this->maxIdleQuantity($channel);
if ($this->checkCanUse($name, $connection)) {
return $connection;
}
@@ -134,15 +133,17 @@ class Pool extends Component
/**
* @param $channel
* @return mixed
* @throws ConfigException
* @throws Exception
*/
private function maxIdleQuantity($channel): void
private function maxIdleQuantity($channel): mixed
{
$connection = $channel->pop();
$minx = Config::get('databases.pool.min', 1);
if ($channel->length() > $minx) {
$this->pop($channel, $minx);
}
return $connection;
}