diff --git a/Database/Connection.php b/Database/Connection.php index 0c8113c8..0e7960a6 100644 --- a/Database/Connection.php +++ b/Database/Connection.php @@ -199,10 +199,12 @@ class Connection extends Component /** * @return \Snowflake\Pool\Connection * @throws ComponentException + * @throws NotFindClassException + * @throws ReflectionException */ private function connections(): \Snowflake\Pool\Connection { - return Snowflake::app()->getConnections(); + return Snowflake::app()->getMysqlFromPool(); } @@ -286,8 +288,9 @@ class Connection extends Component /** - * 临时回收 * @throws ComponentException + * @throws NotFindClassException + * @throws ReflectionException */ public function recovery() { diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index 01ce4079..111e318f 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -286,25 +286,28 @@ abstract class BaseApplication extends Service /** * @return Connection + * @throws ComponentException + * @throws NotFindClassException * @throws ReflectionException - * @throws NotFindClassException|ComponentException */ - public function getConnections(): Connection + public function getMysqlFromPool(): Connection { - return $this->get('connections'); + return $this->get('pool')->getDb(); } /** - * @return SPool + * @throws ComponentException + * @throws NotFindClassException * @throws ReflectionException - * @throws NotFindClassException|ComponentException + * @return SRedis */ - public function getPool(): SPool + public function getRedisFromPool(): SRedis { - return $this->get('pool'); + return $this->get('pool')->getRedis(); } + /** * @return Response * @throws ReflectionException diff --git a/System/Cache/Redis.php b/System/Cache/Redis.php index 521a143f..29811d70 100644 --- a/System/Cache/Redis.php +++ b/System/Cache/Redis.php @@ -10,11 +10,13 @@ declare(strict_types=1); namespace Snowflake\Cache; use Exception; +use ReflectionException; use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; use Snowflake\Event; use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; +use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; /** @@ -44,12 +46,14 @@ class Redis extends Component /** - * @throws ConfigException * @throws ComponentException + * @throws ConfigException + * @throws ReflectionException + * @throws NotFindClassException */ public function createPool() { - $connections = Snowflake::app()->getPool()->getRedis(); + $connections = Snowflake::app()->getRedisFromPool(); $config = $this->get_config(); $name = $config['host'] . ':' . $config['prefix'] . ':' . $config['databases']; @@ -110,13 +114,14 @@ SCRIPT; /** - * 释放连接池 - * @throws ConfigException * @throws ComponentException + * @throws ConfigException + * @throws NotFindClassException + * @throws ReflectionException */ public function release() { - $connections = Snowflake::app()->getPool()->getRedis(); + $connections = Snowflake::app()->getRedisFromPool(); $connections->release($this->get_config(), true); } @@ -128,7 +133,7 @@ SCRIPT; */ public function destroy() { - $connections = Snowflake::app()->getPool()->getRedis(); + $connections = Snowflake::app()->getRedisFromPool(); $connections->destroy($this->get_config(), true); } @@ -138,7 +143,7 @@ SCRIPT; */ public function proxy(): \Redis { - $connections = Snowflake::app()->getPool()->getRedis(); + $connections = Snowflake::app()->getRedisFromPool(); $client = $connections->get($this->get_config(), true); if (!($client instanceof \Redis)) {