This commit is contained in:
2021-09-02 14:29:55 +08:00
parent 7ae96a0521
commit bc7c5ad13b
+15
View File
@@ -120,6 +120,7 @@ class Pool extends Component
$channel = $this->getChannel($name);
if (!$channel->isEmpty()) {
$connection = $channel->pop();
defer(fn() => $this->maxIdleQuantity($channel));
if ($this->checkCanUse($name, $connection)) {
return $connection;
}
@@ -128,6 +129,20 @@ class Pool extends Component
}
/**
* @param $channel
* @throws ConfigException
* @throws Exception
*/
private function maxIdleQuantity($channel): void
{
$minx = Config::get('databases.pool.min', 1);
if ($channel->length() > $minx) {
$this->pop($channel, $minx);
}
}
/**
* @param $name
* @return bool