This commit is contained in:
2021-01-12 18:13:02 +08:00
parent 1aef7786ed
commit f488a14d5b
3 changed files with 11 additions and 6 deletions
+2 -2
View File
@@ -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');
}
+4 -2
View File
@@ -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)) {
+5 -2
View File
@@ -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');
}