mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-08 11:05:59 +08:00
cache
This commit is contained in:
@@ -120,6 +120,9 @@ func (g *groupDatabase) CreateGroup(ctx context.Context, groups []*relationTb.Gr
|
||||
return err
|
||||
}
|
||||
}
|
||||
createGroupIDs := utils.DistinctAnyGetComparable(groups, func(group *relationTb.GroupModel) string {
|
||||
return group.GroupID
|
||||
})
|
||||
m := make(map[string]struct{})
|
||||
var cache = g.cache.NewCache()
|
||||
for _, groupMember := range groupMembers {
|
||||
@@ -127,8 +130,9 @@ func (g *groupDatabase) CreateGroup(ctx context.Context, groups []*relationTb.Gr
|
||||
m[groupMember.GroupID] = struct{}{}
|
||||
cache = cache.DelGroupMemberIDs(groupMember.GroupID).DelGroupMembersHash(groupMember.GroupID).DelGroupsMemberNum(groupMember.GroupID)
|
||||
}
|
||||
cache.DelJoinedGroupID(groupMember.UserID).DelGroupMembersInfo(groupMember.GroupID, groupMember.UserID)
|
||||
cache = cache.DelJoinedGroupID(groupMember.UserID).DelGroupMembersInfo(groupMember.GroupID, groupMember.UserID)
|
||||
}
|
||||
cache = cache.DelGroupsInfo(createGroupIDs...)
|
||||
return cache.ExecDel(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,7 +76,17 @@ func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*rel
|
||||
|
||||
// 插入多条 外部保证userID 不重复 且在db中不存在
|
||||
func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
return u.userDB.Create(ctx, users)
|
||||
return u.tx.Transaction(func(tx any) error {
|
||||
err = u.userDB.Create(ctx, users)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var userIDs []string
|
||||
for _, user := range users {
|
||||
userIDs = append(userIDs, user.UserID)
|
||||
}
|
||||
return u.cache.DelUsersInfo(userIDs...).ExecDel(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
// 更新(非零值) 外部保证userID存在
|
||||
|
||||
Reference in New Issue
Block a user