From add36ab75c3a64df496b6988419e7141e00cc3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 16 Aug 2023 16:35:54 +0800 Subject: [PATCH] qqq --- Connection.php | 5 ++++- DatabasesProviders.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Connection.php b/Connection.php index b369818..bb5fad3 100644 --- a/Connection.php +++ b/Connection.php @@ -49,6 +49,9 @@ class Connection extends Component public int $connect_timeout = 30; + + public int $waite_time = 3; + public int $idle_time = 600; public array $pool = ['max' => 10, 'min' => 1]; @@ -150,7 +153,7 @@ class Connection extends Component */ protected function getNormalClientHealth(): PDO { - [$client, $time] = $this->pool()->get($this->cds); + [$client, $time] = $this->pool()->get($this->cds, $this->waite_time); if ((time() - $time) < $this->idle_time || $this->canUse($client)) { return $client; diff --git a/DatabasesProviders.php b/DatabasesProviders.php index 04a1061..ddabb97 100644 --- a/DatabasesProviders.php +++ b/DatabasesProviders.php @@ -65,6 +65,7 @@ class DatabasesProviders extends Providers 'database' => $database['database'], 'connect_timeout' => $database['connect_timeout'] ?? 10, 'idle_time' => $database['idle_time'] ?? 300, + 'waite_time' => $database['waite_time'] ?? 3, 'pool' => $clientPool, 'attributes' => $database['attributes'] ?? [], 'charset' => $database['charset'] ?? 'utf8mb4'