File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed
config/plugin/webman/redis-queue Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ protected static function connect($config)
50
50
if (!extension_loaded ('redis ' )) {
51
51
throw new \RuntimeException ('Please make sure the PHP Redis extension is installed and enabled. ' );
52
52
}
53
-
53
+
54
54
$ redis = new RedisConnection ();
55
55
$ address = $ config ['host ' ];
56
56
$ config = [
@@ -60,6 +60,7 @@ protected static function connect($config)
60
60
'auth ' => $ config ['options ' ]['auth ' ] ?? '' ,
61
61
'timeout ' => $ config ['options ' ]['timeout ' ] ?? 2 ,
62
62
'ping ' => $ config ['options ' ]['ping ' ] ?? 55 ,
63
+ 'prefix ' => $ config ['options ' ]['prefix ' ] ?? '' ,
63
64
];
64
65
$ redis ->connectWithConfig ($ config );
65
66
return $ redis ;
Original file line number Diff line number Diff line change 19
19
class RedisConnection extends \Redis
20
20
{
21
21
/**
22
- * @var array
22
+ * @var array
23
23
*/
24
24
protected $ config = [];
25
25
@@ -42,6 +42,9 @@ public function connectWithConfig(array $config = [])
42
42
if (!empty ($ this ->config ['db ' ])) {
43
43
$ this ->select ($ this ->config ['db ' ]);
44
44
}
45
+ if (!empty ($ this ->config ['prefix ' ])) {
46
+ $ this ->setOption (\Redis::OPT_PREFIX , $ this ->config ['prefix ' ]);
47
+ }
45
48
if (Worker::getAllWorkers () && !$ timer ) {
46
49
$ timer = Timer::add ($ this ->config ['ping ' ] ?? 55 , function () {
47
50
$ this ->execCommand ('ping ' );
Original file line number Diff line number Diff line change 5
5
'options ' => [
6
6
'auth ' => null , // 密码,字符串类型,可选参数
7
7
'db ' => 0 , // 数据库
8
+ 'prefix ' => '' , // key 前缀
8
9
'max_attempts ' => 5 , // 消费失败后,重试次数
9
10
'retry_seconds ' => 5 , // 重试间隔,单位秒
10
11
]
You can’t perform that action at this time.
0 commit comments