From 95c19b7fac3c4d0705c9b25bb37deb7e1b98330e Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 30 Jun 2023 19:28:08 +0800 Subject: [PATCH 1/2] fix: delete conversation empty cache --- pkg/common/db/controller/conversation.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index d7e955e6b..9845d268b 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -87,7 +87,7 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, if err != nil { return err } - cache = cache.DelConversationIDs(NotUserIDs...).DelUserConversationIDsHash(NotUserIDs...) + cache = cache.DelConversationIDs(NotUserIDs...).DelUserConversationIDsHash(NotUserIDs...).DelConvsersations(conversation.ConversationID, NotUserIDs...) } return nil }); err != nil { @@ -194,6 +194,7 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs for _, conversation := range conversations { if !utils.IsContain(conversation.ConversationID, existConversationIDs) { notExistConversations = append(notExistConversations, conversation) + cache = cache.DelConvsersations(ownerUserID, conversation.ConversationID) } } if len(notExistConversations) > 0 { @@ -228,6 +229,7 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, for _, v := range notExistUserIDs { conversation := relationTb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID} conversations = append(conversations, &conversation) + cache = cache.DelConvsersations(v, conversationID) } cache = cache.DelConversationIDs(notExistUserIDs...).DelUserConversationIDsHash(notExistUserIDs...) if len(conversations) > 0 { From d84530458a76032952ddce0fb36218c5e8250e67 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 30 Jun 2023 19:43:17 +0800 Subject: [PATCH 2/2] fix conversation del empty cache --- pkg/common/db/controller/conversation.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index 9845d268b..62c57c0fc 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -171,6 +171,7 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs var conversationIDs []string for _, conversation := range conversations { conversationIDs = append(conversationIDs, conversation.ConversationID) + cache = cache.DelConvsersations(conversation.OwnerUserID, conversation.ConversationID) } conversationTx := c.conversationDB.NewTx(tx) existConversations, err := conversationTx.Find(ctx, ownerUserID, conversationIDs) @@ -194,7 +195,6 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs for _, conversation := range conversations { if !utils.IsContain(conversation.ConversationID, existConversationIDs) { notExistConversations = append(notExistConversations, conversation) - cache = cache.DelConvsersations(ownerUserID, conversation.ConversationID) } } if len(notExistConversations) > 0 { @@ -204,7 +204,6 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs } cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID) } - cache = cache.DelConvsersations(ownerUserID, existConversationIDs...) return nil }); err != nil { return err