|
|
|
@ -51,7 +51,7 @@ func NewTask() {
|
|
|
|
|
|
|
|
|
|
func task(start, end int64) error { |
|
|
|
|
redisClient := NewRedis() |
|
|
|
|
result, err := redisClient.ZRange(context.Background(), hotKey, start, end).Result() |
|
|
|
|
result, err := redisClient.ZRangeWithScores(context.Background(), hotKey, start, end).Result() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
@ -62,26 +62,29 @@ func task(start, end int64) error {
|
|
|
|
|
members []redis.Z |
|
|
|
|
ids []int64 |
|
|
|
|
) |
|
|
|
|
for _, id := range result { |
|
|
|
|
i, _ := strconv.Atoi(id) |
|
|
|
|
if i != 0 { |
|
|
|
|
ids = append(ids, int64(i)) |
|
|
|
|
} |
|
|
|
|
for _, val := range result { |
|
|
|
|
|
|
|
|
|
if val.Score > 0 { |
|
|
|
|
id, _ := strconv.Atoi(val.Member.(string)) |
|
|
|
|
if id != 0 { |
|
|
|
|
ids = append(ids, int64(id)) |
|
|
|
|
members = append(members, redis.Z{ |
|
|
|
|
Member: id, |
|
|
|
|
Score: 0, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if len(ids) != 0 { |
|
|
|
|
err = redisClient.ZAdd(context.Background(), hotKey, members...).Err() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
roomClient, roomClientClose, err := client.GetRoomClientV2(context.Background()) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
defer roomClientClose() |
|
|
|
|
defer func() { _ = roomClientClose() }() |
|
|
|
|
_, err = roomClient.IncrRoomHotspot(context.Background(), &v2.IncrRoomHotspotReq{ |
|
|
|
|
RoomIdList: ids, |
|
|
|
|
HotValue: 0, |
|
|
|
@ -89,6 +92,7 @@ func task(start, end int64) error {
|
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 递增查询
|
|
|
|
|
start = end + 1 |
|
|
|
|
end = start + 10000 |
|
|
|
|