Commit ba802a38 authored by hujiebin's avatar hujiebin

用redisCluster中的zset代替,只是取出大于100的

parent b6f697a4
......@@ -8,6 +8,7 @@ import (
"git.hilo.cn/hilo-common/resource/redisCli"
"github.com/bluele/gcache"
redis2 "github.com/go-redis/redis/v8"
"github.com/spf13/cast"
"hilo-group/_const/redis_key"
"strconv"
"time"
......@@ -86,6 +87,20 @@ func MGetRoomVisitCount(groupIds []string) (map[string]string, error) {
if len(groupIds) <= 0 {
return visit, nil
}
// 用redisCluster中的zset代替,只是取出大于100的
zKey := redis_key.GetPrefixRoomVisitCountZset()
zRes, err := redisCli.GetClusterRedis().ZRevRangeByScoreWithScores(context.Background(), zKey, &redis2.ZRangeBy{
Min: fmt.Sprintf("%d", 100), // 100人数以上的。
Max: "+inf",
}).Result()
if err != nil {
mylogrus.MyLog.Errorf("MGetRoomVisitCount zset fail:%v", err)
return visit, err
}
for _, v := range zRes {
visit[cast.ToString(v.Member)] = cast.ToString(v.Score)
}
return visit, nil
var miss []string
for _, groupId := range groupIds {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment