add comment message push

This commit is contained in:
landaiqing
2024-09-27 00:42:05 +08:00
parent 372835296d
commit 03c5b92515
5 changed files with 198 additions and 66 deletions

View File

@@ -12,5 +12,6 @@ const (
// 登录之后
const (
CommentSubmitCaptchaRedisKey = "comment:submit:captcha:"
CommentSubmitCaptchaRedisKey = "comment:submit:captcha:"
CommentOfflineMessageRedisKey = "comment:offline:message:"
)

View File

@@ -394,3 +394,16 @@ func ZRem(key string, members ...interface{}) *redis.IntCmd {
func ZRemRangeByRank(key string, start, stop int64) *redis.IntCmd {
return global.REDIS.ZRemRangeByRank(ctx, key, start, stop)
}
// Publish 发布消息到redis
// channel是发布的目标信道
// payload是要发布的消息内容
func Publish(channel string, payload interface{}) *redis.IntCmd {
return global.REDIS.Publish(ctx, channel, payload)
}
// Subscribe 订阅redis消息
// channels是要订阅的信道列表
func Subscribe(channels ...string) *redis.PubSub {
return global.REDIS.Subscribe(ctx, channels...)
}