From e8c2e634390771eeff0ba69151c5a03bd02b1b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 16 Feb 2021 23:47:41 +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 | 7 +++---- System/Pool/Connection.php | 5 +---- System/Pool/Redis.php | 5 +---- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index bf5b654d..2d58281f 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -127,11 +127,10 @@ abstract class Pool extends Component public function createConnect(array $config, string $coroutineName, callable $createHandler): PDO|Redis|false { if (Context::hasContext('create:connect:' . $coroutineName)) { - while (!($client = Context::hasContext($coroutineName))){ + while (!($client = Context::getContext($coroutineName))){ var_dump($client); } - var_dump($client); - return true; + return $client; } Context::setContext('create:connect:' . $coroutineName, 1); @@ -139,7 +138,7 @@ abstract class Pool extends Component Context::deleteId('create:connect:' . $coroutineName); - return $client; + return Context::setContext($coroutineName, $client); } diff --git a/System/Pool/Connection.php b/System/Pool/Connection.php index 5f413564..5a9d37bf 100644 --- a/System/Pool/Connection.php +++ b/System/Pool/Connection.php @@ -151,10 +151,7 @@ class Connection extends Pool return Context::getContext($coroutineName); } if (!$this->hasItem($coroutineName)) { - if (($client = $this->newClient($config, $coroutineName)) == true) { - return Context::getContext($coroutineName); - } - return Context::setContext($coroutineName, $client); + return $this->newClient($config, $coroutineName); } [$time, $connections] = $this->get($coroutineName); if (!($connections instanceof PDO)) { diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index ceec757d..1245fe65 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -47,10 +47,7 @@ class Redis extends Pool return Context::getContext($coroutineName); } if (!$this->hasItem($coroutineName)) { - if (($client = $this->newClient($config, $coroutineName)) == true) { - return Context::getContext($coroutineName); - } - return Context::setContext($coroutineName, $client); + return $this->newClient($config, $coroutineName); } [$time, $clients] = $this->get($coroutineName); if ($clients === null) {