改名
This commit is contained in:
@@ -13,6 +13,7 @@ use Snowflake\Abstracts\Component;
|
|||||||
use Snowflake\Config;
|
use Snowflake\Config;
|
||||||
use Snowflake\Event;
|
use Snowflake\Event;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
|
use Snowflake\Exception\RedisConnectException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
|
|
||||||
@@ -284,6 +285,9 @@ class Redis extends Component
|
|||||||
$data = $this->proxy()->{$name}(...$arguments);
|
$data = $this->proxy()->{$name}(...$arguments);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
if ($exception instanceof RedisConnectException) {
|
||||||
|
throw new Exception($exception->getMessage());
|
||||||
|
}
|
||||||
$this->error(print_r($exception, true));
|
$this->error(print_r($exception, true));
|
||||||
$data = false;
|
$data = false;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Snowflake\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
class RedisConnectException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace Snowflake\Pool;
|
|||||||
use HttpServer\Http\Context;
|
use HttpServer\Http\Context;
|
||||||
use Redis as SRedis;
|
use Redis as SRedis;
|
||||||
use RedisException;
|
use RedisException;
|
||||||
|
use Snowflake\Exception\RedisConnectException;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
@@ -88,10 +89,10 @@ class Redis extends Pool
|
|||||||
{
|
{
|
||||||
$redis = new SRedis();
|
$redis = new SRedis();
|
||||||
if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) {
|
if (!$redis->connect($config['host'], $config['port'], $config['timeout'])) {
|
||||||
throw new Exception(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
throw new RedisConnectException(sprintf('The Redis Connect %s::%d Fail.', $config['host'], $config['port']));
|
||||||
}
|
}
|
||||||
if (empty($config['auth']) || !$redis->auth($config['auth'])) {
|
if (empty($config['auth']) || !$redis->auth($config['auth'])) {
|
||||||
throw new Exception(sprintf('Redis Error: %s, Host %s, Auth %s', $redis->getLastError(), $config['host'], $config['auth']));
|
throw new RedisConnectException(sprintf('Redis Error: %s, Host %s, Auth %s', $redis->getLastError(), $config['host'], $config['auth']));
|
||||||
}
|
}
|
||||||
if (!isset($config['read_timeout'])) {
|
if (!isset($config['read_timeout'])) {
|
||||||
$config['read_timeout'] = 10;
|
$config['read_timeout'] = 10;
|
||||||
|
|||||||
Reference in New Issue
Block a user