From f488a14d5ba47a0747afcdaf2e2b2ae39b4e7939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 12 Jan 2021 18:13:02 +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/BaseApplication.php | 4 ++-- System/Cache/Redis.php | 6 ++++-- System/Pool/Pool.php | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index 4c67c3e3..01ab2b96 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -296,10 +296,10 @@ abstract class BaseApplication extends Service /** - * @return Pool + * @return SPool * @throws ComponentException */ - public function getPool(): Pool + public function getPool(): SPool { return $this->get('pool'); } diff --git a/System/Cache/Redis.php b/System/Cache/Redis.php index 7115c0e6..ea09958b 100644 --- a/System/Cache/Redis.php +++ b/System/Cache/Redis.php @@ -13,6 +13,7 @@ use Exception; use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; use Snowflake\Event; +use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -121,10 +122,11 @@ SCRIPT; /** * 销毁连接池 * @throws ConfigException + * @throws ComponentException */ public function destroy() { - $connections = Snowflake::app()->pool->redis; + $connections = Snowflake::app()->getPool()->getRedis(); $connections->destroy($this->get_config(), true); } @@ -134,7 +136,7 @@ SCRIPT; */ public function proxy(): \Redis { - $connections = Snowflake::app()->pool->redis; + $connections = Snowflake::app()->getPool()->getRedis(); $client = $connections->getConnection($this->get_config(), true); if (!($client instanceof \Redis)) { diff --git a/System/Pool/Pool.php b/System/Pool/Pool.php index 30be0dd4..8fadbc2b 100644 --- a/System/Pool/Pool.php +++ b/System/Pool/Pool.php @@ -6,6 +6,7 @@ namespace Snowflake\Pool; +use Snowflake\Exception\ComponentException; use Snowflake\Snowflake; /** @@ -20,18 +21,20 @@ class Pool extends \Snowflake\Abstracts\Pool /** * @return Redis + * @throws ComponentException */ public function getRedis(): Redis { - return Snowflake::app()->redis_connections; + return Snowflake::app()->get('redis_connections'); } /** * @return Connection + * @throws ComponentException */ public function getDb(): Connection { - return Snowflake::app()->connections; + return Snowflake::app()->get('connections'); }