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'); }