@@ -14,7 +14,7 @@ class RedisRegistrar implements RegistrarInterface
1414 /** @inheritDoc */
1515 public function get (string $ name , string $ ip , int $ port ): ?array
1616 {
17- $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-register ' )->client ();
17+ $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-registrar ' )->client ();
1818 try {
1919 $ result = $ client ->hGetAll ($ this ->_registrarKey ($ name , $ ip , $ port ));
2020 foreach ($ result as &$ value ) {
@@ -36,7 +36,7 @@ public function get(string $name, string $ip, int $port): ?array
3636 /** @inheritDoc */
3737 public function query (?string $ name ): ?array
3838 {
39- $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-register ' )->client ();
39+ $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-registrar ' )->client ();
4040 $ hash = [];
4141 try {
4242 while (
@@ -68,8 +68,12 @@ public function register(string $name, string $ip, int $port, string|null $worke
6868 {
6969 $ workerId = $ workerId ?: '' ;
7070 try {
71- $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-register ' )->client ();
72- $ res = $ client ->hSet ($ key = $ this ->_registrarKey ($ name , $ ip , $ port ), $ workerId , json_encode ($ metadata , JSON_UNESCAPED_UNICODE ));
71+ $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-registrar ' )->client ();
72+ $ res = $ client ->hSet (
73+ $ key = $ this ->_registrarKey ($ name , $ ip , $ port ),
74+ $ workerId ,
75+ $ metadata ? json_encode ($ metadata , JSON_UNESCAPED_UNICODE ) : '{} '
76+ );
7377 // 如果存在定时间隔,则存在定时上报,则开启键值过期
7478 if ($ interval = config ('plugin.workbunny.webman-push-server.registrar.interval ' )) {
7579 $ client ->expire ($ key , $ interval * 1.5 );
@@ -92,8 +96,12 @@ public function report(string $name, string $ip, int $port, string|null $workerI
9296 {
9397 $ workerId = $ workerId ?: '' ;
9498 try {
95- $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-register ' )->client ();
96- $ res = $ client ->hSet ($ key = $ this ->_registrarKey ($ name , $ ip , $ port ), $ workerId , json_encode ($ metadata , JSON_UNESCAPED_UNICODE ));
99+ $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-registrar ' )->client ();
100+ $ res = $ client ->hSet (
101+ $ key = $ this ->_registrarKey ($ name , $ ip , $ port ),
102+ $ workerId ,
103+ $ metadata ? json_encode ($ metadata , JSON_UNESCAPED_UNICODE ) : '{} '
104+ );
97105 // 如果存在定时间隔,则存在定时上报,则开启键值过期
98106 if ($ interval = config ('plugin.workbunny.webman-push-server.registrar.interval ' )) {
99107 $ client ->expire ($ key , $ interval * 1.5 );
@@ -116,7 +124,7 @@ public function unregister(string $name, string $ip, int $port, string|null $wor
116124 {
117125 $ workerId = $ workerId ?: '' ;
118126 try {
119- $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-register ' )->client ();
127+ $ client = Redis::connection ('plugin.workbunny.webman-push-server.server-registrar ' )->client ();
120128 return boolval (
121129 $ client ->hDel ($ this ->_registrarKey ($ name , $ ip , $ port ), $ workerId )
122130 );
0 commit comments