Skip to content

Commit a6e61a3

Browse files
committed
Throw exceptions when the redis option key is invalid.
1 parent cb0dcc9 commit a6e61a3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace Hyperf\Redis\Exception;
13+
14+
use RuntimeException;
15+
16+
class InvalidRedisOptionException extends RuntimeException
17+
{
18+
}

src/RedisConnection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Hyperf\Pool\Connection as BaseConnection;
1818
use Hyperf\Pool\Exception\ConnectionException;
1919
use Hyperf\Redis\Exception\InvalidRedisConnectionException;
20+
use Hyperf\Redis\Exception\InvalidRedisOptionException;
2021
use Psr\Container\ContainerInterface;
2122
use Psr\Log\LogLevel;
2223
use Redis;
@@ -131,7 +132,7 @@ public function reconnect(): bool
131132
'compression' => Redis::OPT_COMPRESSION, // 7
132133
'reply_literal' => Redis::OPT_REPLY_LITERAL, // 8
133134
'compression_level' => Redis::OPT_COMPRESSION_LEVEL, // 9
134-
default => $name,
135+
default => throw new InvalidRedisOptionException(sprintf('The redis option key `%s` is invalid.', $name)),
135136
};
136137
}
137138
$redis->setOption($name, $value);

0 commit comments

Comments
 (0)