This commit is contained in:
wangchuxiao
2023-01-30 11:10:26 +08:00
parent d6edb4aa8c
commit 21a1e7dff2
23 changed files with 173 additions and 285 deletions
+3 -3
View File
@@ -56,7 +56,7 @@ func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *r
}
group = &relation.Group{}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
}()
groupStr, err := g.rcClient.Fetch(g.getGroupInfoCacheKey(groupID), g.expireTime, getGroup)
if err != nil {
@@ -68,7 +68,7 @@ func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *r
func (g *GroupCache) DelGroupInfo(ctx context.Context, groupID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return g.rcClient.TagAsDeleted(g.getGroupInfoCacheKey(groupID))
}
@@ -96,7 +96,7 @@ func (g *GroupCache) DelJoinedSuperGroupIDs(ctx context.Context, userIDs []strin
func (g *GroupCache) DelJoinedSuperGroupID(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return g.rcClient.TagAsDeleted(joinedSuperGroupListCache + userID)
}
+31 -31
View File
@@ -85,7 +85,7 @@ func (rc *Client) GetFriendIDListFromCache(ctx context.Context, userID string) (
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "friendIDList", friendIDList)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "friendIDList", friendIDList)
}()
friendIDListStr, err := db.DB.Rc.Fetch(friendRelationCache+userID, time.Second*30*60, getFriendIDList)
if err != nil {
@@ -97,7 +97,7 @@ func (rc *Client) GetFriendIDListFromCache(ctx context.Context, userID string) (
func DelFriendIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(friendRelationCache + userID)
}
@@ -115,7 +115,7 @@ func GetBlackListFromCache(ctx context.Context, userID string) (blackIDs []strin
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "blackIDList", blackIDs)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "blackIDList", blackIDs)
}()
blackIDListStr, err := db.DB.Rc.Fetch(blackListCache+userID, time.Second*30*60, getBlackIDList)
if err != nil {
@@ -127,7 +127,7 @@ func GetBlackListFromCache(ctx context.Context, userID string) (blackIDs []strin
func DelBlackIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ctx", ctx)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ctx", ctx)
}()
return db.DB.Rc.TagAsDeleted(blackListCache + userID)
}
@@ -145,7 +145,7 @@ func GetJoinedGroupIDListFromCache(ctx context.Context, userID string) (joinedGr
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedGroupList", joinedGroupList)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedGroupList", joinedGroupList)
}()
joinedGroupIDListStr, err := db.DB.Rc.Fetch(joinedGroupListCache+userID, time.Second*30*60, getJoinedGroupIDList)
if err != nil {
@@ -157,7 +157,7 @@ func GetJoinedGroupIDListFromCache(ctx context.Context, userID string) (joinedGr
func DelJoinedGroupIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(joinedGroupListCache + userID)
}
@@ -188,7 +188,7 @@ func GetGroupMemberIDListFromCache(ctx context.Context, groupID string) (groupMe
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMemberIDList", groupMemberIDList)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMemberIDList", groupMemberIDList)
}()
groupIDListStr, err := db.DB.Rc.Fetch(groupCache+groupID, time.Second*30*60, f)
if err != nil {
@@ -200,7 +200,7 @@ func GetGroupMemberIDListFromCache(ctx context.Context, groupID string) (groupMe
func DelGroupMemberIDListFromCache(ctx context.Context, groupID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return db.DB.Rc.TagAsDeleted(groupCache + groupID)
}
@@ -218,7 +218,7 @@ func GetUserInfoFromCache(ctx context.Context, userID string) (userInfo *relatio
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "userInfo", *userInfo)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "userInfo", *userInfo)
}()
userInfoStr, err := db.DB.Rc.Fetch(userInfoCache+userID, time.Second*30*60, getUserInfo)
if err != nil {
@@ -243,7 +243,7 @@ func GetUserInfoFromCacheBatch(ctx context.Context, userIDs []string) ([]*relati
func DelUserInfoFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(userInfoCache + userID)
}
@@ -261,7 +261,7 @@ func GetGroupMemberInfoFromCache(ctx context.Context, groupID, userID string) (g
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
}()
groupMemberInfoStr, err := db.DB.Rc.Fetch(groupMemberInfoCache+groupID+"-"+userID, time.Second*30*60, getGroupMemberInfo)
if err != nil {
@@ -274,14 +274,14 @@ func GetGroupMemberInfoFromCache(ctx context.Context, groupID, userID string) (g
func DelGroupMemberInfoFromCache(ctx context.Context, groupID, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(groupMemberInfoCache + groupID + "-" + userID)
}
func GetGroupMembersInfoFromCache(ctx context.Context, count, offset int32, groupID string) (groupMembers []*relation.GroupMember, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "count", count, "offset", offset, "groupID", groupID, "groupMember", groupMembers)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "count", count, "offset", offset, "groupID", groupID, "groupMember", groupMembers)
}()
groupMemberIDList, err := GetGroupMemberIDListFromCache(ctx, groupID)
if err != nil {
@@ -328,7 +328,7 @@ func GetGroupMembersInfoFromCache(ctx context.Context, count, offset int32, grou
func GetAllGroupMembersInfoFromCache(ctx context.Context, groupID string) (groupMembers []*relation.GroupMember, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMembers", groupMembers)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMembers", groupMembers)
}()
getGroupMemberInfo := func() (string, error) {
groupMembers, err := relation.GetGroupMemberListByGroupID(groupID)
@@ -351,7 +351,7 @@ func GetAllGroupMembersInfoFromCache(ctx context.Context, groupID string) (group
func DelAllGroupMembersInfoFromCache(ctx context.Context, groupID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return db.DB.Rc.TagAsDeleted(groupAllMemberInfoCache + groupID)
}
@@ -400,7 +400,7 @@ func GetAllFriendsInfoFromCache(ctx context.Context, userID string) (friends []*
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "friends", friends)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "friends", friends)
}()
allFriendInfoStr, err := db.DB.Rc.Fetch(allFriendInfoCache+userID, time.Second*30*60, getAllFriendInfo)
if err != nil {
@@ -412,7 +412,7 @@ func GetAllFriendsInfoFromCache(ctx context.Context, userID string) (friends []*
func DelAllFriendsInfoFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(allFriendInfoCache + userID)
}
@@ -430,7 +430,7 @@ func GetJoinedSuperGroupListFromCache(ctx context.Context, userID string) (joine
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedSuperGroupIDs", joinedSuperGroupIDs)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedSuperGroupIDs", joinedSuperGroupIDs)
}()
joinedSuperGroupListStr, err := db.DB.Rc.Fetch(joinedSuperGroupListCache+userID, time.Second*30*60, getJoinedSuperGroupIDList)
if err != nil {
@@ -442,7 +442,7 @@ func GetJoinedSuperGroupListFromCache(ctx context.Context, userID string) (joine
func DelJoinedSuperGroupIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return db.DB.Rc.TagAsDeleted(joinedSuperGroupListCache + userID)
}
@@ -470,7 +470,7 @@ func GetGroupMemberListHashFromCache(ctx context.Context, groupID string) (hashC
return strconv.Itoa(int(bi.Uint64())), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "hashCodeUint64", hashCodeUint64)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "hashCodeUint64", hashCodeUint64)
}()
hashCodeStr, err := db.DB.Rc.Fetch(groupMemberListHashCache+groupID, time.Second*30*60, generateHash)
if err != nil {
@@ -482,7 +482,7 @@ func GetGroupMemberListHashFromCache(ctx context.Context, groupID string) (hashC
func DelGroupMemberListHashFromCache(ctx context.Context, groupID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return db.DB.Rc.TagAsDeleted(groupMemberListHashCache + groupID)
}
@@ -496,7 +496,7 @@ func GetGroupMemberNumFromCache(ctx context.Context, groupID string) (num int, e
return strconv.Itoa(int(num)), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "num", num)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "num", num)
}()
groupMember, err := db.DB.Rc.Fetch(groupMemberNumCache+groupID, time.Second*30*60, getGroupMemberNum)
if err != nil {
@@ -507,7 +507,7 @@ func GetGroupMemberNumFromCache(ctx context.Context, groupID string) (num int, e
func DelGroupMemberNumFromCache(ctx context.Context, groupID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return db.DB.Rc.TagAsDeleted(groupMemberNumCache + groupID)
}
@@ -526,7 +526,7 @@ func GetUserConversationIDListFromCache(ctx context.Context, userID string) (con
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversationIDs", conversationIDs)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "conversationIDs", conversationIDs)
}()
conversationIDListStr, err := db.DB.Rc.Fetch(conversationIDListCache+userID, time.Second*30*60, getConversationIDList)
err = json.Unmarshal([]byte(conversationIDListStr), &conversationIDs)
@@ -538,7 +538,7 @@ func GetUserConversationIDListFromCache(ctx context.Context, userID string) (con
func DelUserConversationIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return utils.Wrap(db.DB.Rc.TagAsDeleted(conversationIDListCache+userID), "DelUserConversationIDListFromCache err")
}
@@ -556,7 +556,7 @@ func GetConversationFromCache(ctx context.Context, ownerUserID, conversationID s
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID, "conversation", *conversation)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID, "conversation", *conversation)
}()
conversationStr, err := db.DB.Rc.Fetch(conversationCache+ownerUserID+":"+conversationID, time.Second*30*60, getConversation)
if err != nil {
@@ -569,7 +569,7 @@ func GetConversationFromCache(ctx context.Context, ownerUserID, conversationID s
func GetConversationsFromCache(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []relation.Conversation, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationIDs", conversationIDs, "conversations", conversations)
}()
for _, conversationID := range conversationIDs {
conversation, err := GetConversationFromCache(ctx, ownerUserID, conversationID)
@@ -583,7 +583,7 @@ func GetConversationsFromCache(ctx context.Context, ownerUserID string, conversa
func GetUserAllConversationList(ctx context.Context, ownerUserID string) (conversations []relation.Conversation, err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversations", conversations)
}()
IDList, err := GetUserConversationIDListFromCache(ctx, ownerUserID)
if err != nil {
@@ -603,7 +603,7 @@ func GetUserAllConversationList(ctx context.Context, ownerUserID string) (conver
func DelConversationFromCache(ctx context.Context, ownerUserID, conversationID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "conversationID", conversationID)
}()
return utils.Wrap(db.DB.Rc.TagAsDeleted(conversationCache+ownerUserID+":"+conversationID), "DelConversationFromCache err")
}
@@ -621,7 +621,7 @@ func GetExtendMsg(ctx context.Context, sourceID string, sessionType int32, clien
return string(bytes), nil
}
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sourceID", sourceID, "sessionType",
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "sourceID", sourceID, "sessionType",
sessionType, "clientMsgID", clientMsgID, "firstModifyTime", firstModifyTime, "extendMsg", extendMsg)
}()
extendMsgStr, err := db.DB.Rc.Fetch(extendMsgCache+clientMsgID, time.Second*30*60, getExtendMsg)
@@ -635,7 +635,7 @@ func GetExtendMsg(ctx context.Context, sourceID string, sessionType int32, clien
func DelExtendMsg(ctx context.Context, clientMsgID string) (err error) {
defer func() {
trace_log.SetCtxDebug(ctx, utils.GetFuncName(1), err, "clientMsgID", clientMsgID)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "clientMsgID", clientMsgID)
}()
return utils.Wrap(db.DB.Rc.TagAsDeleted(extendMsgCache+clientMsgID), "DelExtendMsg err")
}