qqq
This commit is contained in:
+4
-1
@@ -49,6 +49,9 @@ class Connection extends Component
|
|||||||
|
|
||||||
public int $connect_timeout = 30;
|
public int $connect_timeout = 30;
|
||||||
|
|
||||||
|
|
||||||
|
public int $waite_time = 3;
|
||||||
|
|
||||||
public int $idle_time = 600;
|
public int $idle_time = 600;
|
||||||
|
|
||||||
public array $pool = ['max' => 10, 'min' => 1];
|
public array $pool = ['max' => 10, 'min' => 1];
|
||||||
@@ -150,7 +153,7 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
protected function getNormalClientHealth(): PDO
|
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)) {
|
if ((time() - $time) < $this->idle_time || $this->canUse($client)) {
|
||||||
return $client;
|
return $client;
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class DatabasesProviders extends Providers
|
|||||||
'database' => $database['database'],
|
'database' => $database['database'],
|
||||||
'connect_timeout' => $database['connect_timeout'] ?? 10,
|
'connect_timeout' => $database['connect_timeout'] ?? 10,
|
||||||
'idle_time' => $database['idle_time'] ?? 300,
|
'idle_time' => $database['idle_time'] ?? 300,
|
||||||
|
'waite_time' => $database['waite_time'] ?? 3,
|
||||||
'pool' => $clientPool,
|
'pool' => $clientPool,
|
||||||
'attributes' => $database['attributes'] ?? [],
|
'attributes' => $database['attributes'] ?? [],
|
||||||
'charset' => $database['charset'] ?? 'utf8mb4'
|
'charset' => $database['charset'] ?? 'utf8mb4'
|
||||||
|
|||||||
Reference in New Issue
Block a user