mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Added Redis options name to support string type (#6188)
This commit is contained in:
parent
f1c40efcf1
commit
a5cd1fd8a1
@ -1,5 +1,9 @@
|
||||
# v3.0.39 - TBD
|
||||
|
||||
## Added
|
||||
|
||||
- [#6188](https://github.com/hyperf/hyperf/pull/6188) Added Redis options name to support string type.
|
||||
|
||||
# v3.0.38 - 2023-10-05
|
||||
|
||||
## Fixed
|
||||
|
@ -120,7 +120,20 @@ class RedisConnection extends BaseConnection implements ConnectionInterface
|
||||
$options = $this->config['options'] ?? [];
|
||||
|
||||
foreach ($options as $name => $value) {
|
||||
// The name is int, value is string.
|
||||
if (is_string($name)) {
|
||||
$name = match (strtolower($name)) {
|
||||
'serializer' => Redis::OPT_SERIALIZER, // 1
|
||||
'prefix' => Redis::OPT_PREFIX, // 2
|
||||
'read_timeout' => Redis::OPT_READ_TIMEOUT, // 3
|
||||
'scan' => Redis::OPT_SCAN, // 4
|
||||
'failover' => defined(Redis::class . '::OPT_SLAVE_FAILOVER') ? Redis::OPT_SLAVE_FAILOVER : 5, // 5
|
||||
'keepalive' => Redis::OPT_TCP_KEEPALIVE, // 6
|
||||
'compression' => Redis::OPT_COMPRESSION, // 7
|
||||
'reply_literal' => Redis::OPT_REPLY_LITERAL, // 8
|
||||
'compression_level' => Redis::OPT_COMPRESSION_LEVEL, // 9
|
||||
default => $name,
|
||||
};
|
||||
}
|
||||
$redis->setOption($name, $value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user