添加消息部分用户关系及群用户缓存-修复群缓存构建

This commit is contained in:
junleea 2024-09-21 13:40:26 +08:00
parent f1534502a2
commit ed9a6112d9
1 changed files with 1 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package service
import (
"errors"
"fmt"
"strconv"
"time"
"videoplayer/dao"
@ -19,7 +18,6 @@ func CreateGeneralMessageService(from_id, to_id, msg_type, group_id int, content
//判断是否是好友,判断是否存在缓存,不存在则设置缓存,存在则判断是否是好友
if worker.IsContainKey("user_"+strconv.Itoa(from_id)+"_friends") == false {
//设置好友缓存
fmt.Println("设置好友缓存:", from_id, to_id)
isSuccess := SetFriendCache(from_id)
//设置失败,直接查询数据库
if !isSuccess {
@ -320,6 +318,6 @@ func SetGroupCache(group_id int) bool {
for _, user := range users {
ids = append(ids, strconv.Itoa(user.UserID))
}
res := worker.SetRedisSet("group_"+strconv.Itoa(group_id)+"_groups", ids, time.Hour*12)
res := worker.SetRedisSet("group_"+strconv.Itoa(group_id)+"_users", ids, time.Hour*12)
return res
}