diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index 506fe617..501c55a9 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -146,7 +146,10 @@ abstract class Pool extends Component */ public function hasItem(string $name): bool { - return $this->size($name) > 0; + if (isset($this->_items[$name])) { + return $this->_items[$name]->isEmpty(); + } + return false; } diff --git a/System/Pool/Redis.php b/System/Pool/Redis.php index bc851cd6..a8289506 100644 --- a/System/Pool/Redis.php +++ b/System/Pool/Redis.php @@ -45,25 +45,12 @@ class Redis extends Pool if (Context::hasContext($coroutineName)) { return Context::getContext($coroutineName); } - return $this->getByChannel($coroutineName, $config); - } - - - /** - * @param $coroutineName - * @param $config - * @return mixed - * @throws Exception - */ - public function getByChannel($coroutineName, $config): mixed - { if (!$this->hasItem($coroutineName)) { - $clients = $this->newClient($config, $coroutineName); - } else { - [$time, $clients] = $this->get($coroutineName); - if ($clients === null) { - return $this->getByChannel($coroutineName, $config); - } + return $this->saveClient($coroutineName, $this->newClient($config, $coroutineName)); + } + [$time, $clients] = $this->get($coroutineName); + if ($clients === null) { + return $this->saveClient($coroutineName, $this->newClient($config, $coroutineName)); } return $this->saveClient($coroutineName, $clients); }