Skip to content

Commit cb0dcc9

Browse files
committed
Merge branch 'master' into 3.1-merge
2 parents 0148f8a + 2dbdba4 commit cb0dcc9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

publish/redis.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@
4242
'heartbeat' => -1,
4343
'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60),
4444
],
45+
'options' => [
46+
'prefix' => env('REDIS_PREFIX', ''),
47+
],
4548
],
4649
];

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)