增加 节点类型选择
This commit is contained in:
parent
bf60034518
commit
75a0449ae8
@ -77,13 +77,14 @@ public static function updateThisNode($data = []): void
|
||||
public static function hset($key, $value, $data = []): void
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
Redis::hset(self::$prefix.$key, $value, json_encode($data));
|
||||
Redis::hset(self::$prefix . $key, $value, json_encode($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $events 事件名称
|
||||
* @param $callback callable 回调函数,接收一个参数,为事件数据。
|
||||
* @param $ignore_self bool 是否忽略此节点的消息。
|
||||
* @param string|array $events 事件名称
|
||||
* @param $callback callable 回调函数,接收一个参数,为事件数据。
|
||||
* @param $ignore_self bool 是否忽略此节点的消息。
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function listen(string|array $events, callable $callback, bool $ignore_self = true): void
|
||||
@ -114,13 +115,13 @@ public static function listen(string|array $events, callable $callback, bool $ig
|
||||
public static function get($key, $default = null): string|array|null
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
return Redis::get(self::$prefix.$key, $default);
|
||||
return Redis::get(self::$prefix . $key, $default);
|
||||
}
|
||||
|
||||
public static function forget($key): void
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
Redis::forget(self::$prefix.$key);
|
||||
Redis::forget(self::$prefix . $key);
|
||||
}
|
||||
|
||||
// forever
|
||||
@ -132,18 +133,18 @@ public static function forever($key, $value): void
|
||||
public static function set($key, $value, $ttl = null): void
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
Redis::set(self::$prefix.$key, $value, $ttl);
|
||||
Redis::set(self::$prefix . $key, $value, $ttl);
|
||||
}
|
||||
|
||||
public static function hget($key, $hashKey, $default = []): string|array|null
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$value = Redis::hget(self::$prefix.$key, $hashKey);
|
||||
$value = Redis::hget(self::$prefix . $key, $hashKey);
|
||||
|
||||
return $value ?: $default;
|
||||
}
|
||||
|
||||
public static function nodes($hide_ip = false): array
|
||||
public static function nodes($hide_ip = false, $type = 'all'): array
|
||||
{
|
||||
$nodes = self::hgetAll('nodes');
|
||||
|
||||
@ -156,6 +157,10 @@ public static function nodes($hide_ip = false): array
|
||||
unset($nodes[$key]['ip']);
|
||||
}
|
||||
|
||||
if ($type !== 'all' && $nodes[$key]['type'] !== $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$append_nodes[] = $nodes[$key];
|
||||
}
|
||||
|
||||
@ -165,7 +170,7 @@ public static function nodes($hide_ip = false): array
|
||||
public static function hgetAll($hashKey, $default = []): array
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$value = Redis::hgetall(self::$prefix.$hashKey);
|
||||
$value = Redis::hgetall(self::$prefix . $hashKey);
|
||||
|
||||
return $value ?: $default;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user