You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dorm/redis_curd_channel.go

32 lines
1001 B

2 years ago
package dorm
import (
"context"
4 months ago
"github.com/redis/go-redis/v9"
2 years ago
)
// Subscribe 订阅channel
2 years ago
func (r *RedisClient) Subscribe(ctx context.Context, channels ...string) *redis.PubSub {
4 months ago
return r.db.Subscribe(ctx, channels...)
2 years ago
}
// PSubscribe 订阅channel支持通配符匹配
2 years ago
func (r *RedisClient) PSubscribe(ctx context.Context, channels ...string) *redis.PubSub {
4 months ago
return r.db.PSubscribe(ctx, channels...)
2 years ago
}
// Publish 将信息发送到指定的channel
2 years ago
func (r *RedisClient) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd {
4 months ago
return r.db.Publish(ctx, channel, message)
2 years ago
}
// PubSubChannels 查询活跃的channel
2 years ago
func (r *RedisClient) PubSubChannels(ctx context.Context, pattern string) *redis.StringSliceCmd {
4 months ago
return r.db.PubSubChannels(ctx, pattern)
2 years ago
}
// PubSubNumSub 查询指定的channel有多少个订阅者
2 years ago
func (r *RedisClient) PubSubNumSub(ctx context.Context, channels ...string) *redis.MapStringIntCmd {
4 months ago
return r.db.PubSubNumSub(ctx, channels...)
2 years ago
}