From d2320bead79dedac442608b35c2f8ca8a05b4aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 5 Sep 2020 01:29:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/Pool.php | 12 +++--------- System/Pool/Connection.php | 2 +- System/Pool/Redis.php | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index c20b8be6..8fbabad7 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -38,23 +38,17 @@ abstract class Pool extends Component /** * @param $name - * @param int $timeout * @return mixed * @throws Exception */ - protected function get($name, $timeout = -1) + protected function get($name) { - if ($timeout != -1) { - $client = $this->_items[$name]->pop($timeout); - } else { - $client = $this->_items[$name]->pop(); - } - [$timeout, $connection] = $client; + [$timeout, $connection] = $this->_items[$name]->pop(); if (!$this->checkCanUse($name, $timeout, $connection)) { unset($client); return [0, null]; } else { - return $client; + return [$timeout, $connection]; } } diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index f0857149..4381d4ee 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -190,7 +190,7 @@ class Connection extends Pool */ public function getByChannel($coroutineName, $config) { - [$time, $client] = $this->get($coroutineName, -1); + [$time, $client] = $this->get($coroutineName); if ($client instanceof PDO) { return $this->saveClient($coroutineName, $client); } diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index 12970e9d..c147a5d9 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -60,7 +60,7 @@ class Redis extends Pool $this->success('create redis client -> ' . $config['host'] . ':' . $this->size($coroutineName)); return $this->saveClient($coroutineName, $this->createConnect($config)); } - [$time, $client] = $this->get($coroutineName, -1); + [$time, $client] = $this->get($coroutineName); if ($client === null) { return $this->getByChannel($coroutineName, $config); }