Skip to content

Commit 9187149

Browse files
authored
Added Redis options name to support string type (#6188)
1 parent 270720a commit 9187149

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/RedisConnection.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,20 @@ public function reconnect(): bool
120120
$options = $this->config['options'] ?? [];
121121

122122
foreach ($options as $name => $value) {
123-
// The name is int, value is string.
123+
if (is_string($name)) {
124+
$name = match (strtolower($name)) {
125+
'serializer' => Redis::OPT_SERIALIZER, // 1
126+
'prefix' => Redis::OPT_PREFIX, // 2
127+
'read_timeout' => Redis::OPT_READ_TIMEOUT, // 3
128+
'scan' => Redis::OPT_SCAN, // 4
129+
'failover' => defined(Redis::class . '::OPT_SLAVE_FAILOVER') ? Redis::OPT_SLAVE_FAILOVER : 5, // 5
130+
'keepalive' => Redis::OPT_TCP_KEEPALIVE, // 6
131+
'compression' => Redis::OPT_COMPRESSION, // 7
132+
'reply_literal' => Redis::OPT_REPLY_LITERAL, // 8
133+
'compression_level' => Redis::OPT_COMPRESSION_LEVEL, // 9
134+
default => $name,
135+
};
136+
}
124137
$redis->setOption($name, $value);
125138
}
126139

0 commit comments

Comments
 (0)