feat: local cache

This commit is contained in:
withchao 2024-01-16 11:15:28 +08:00
parent d26a1b2090
commit 1afdd0bcf7
2 changed files with 5 additions and 2 deletions

View File

@ -144,6 +144,7 @@ func (m *msgServer) sendMsgNotification(
} }
func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, err error) { func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq) (resp *pbmsg.SendMsgResp, err error) {
log.ZDebug(ctx, "sendMsgSingleChat return")
if err := m.messageVerification(ctx, req); err != nil { if err := m.messageVerification(ctx, req); err != nil {
return nil, err return nil, err
} }

View File

@ -16,6 +16,7 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/tools/log"
"math/rand" "math/rand"
"strconv" "strconv"
"time" "time"
@ -186,7 +187,8 @@ func (m *msgServer) modifyMessageByUserMessageReceiveOpt(
sessionType int, sessionType int,
pb *msg.SendMsgReq, pb *msg.SendMsgReq,
) (bool, error) { ) (bool, error) {
opt, err := m.User.GetUserGlobalMsgRecvOpt(ctx, userID) defer log.ZDebug(ctx, "modifyMessageByUserMessageReceiveOpt return")
opt, err := m.User.GetUserGlobalMsgRecvOpt(ctx, userID) // todo local cache
if err != nil { if err != nil {
return false, err return false, err
} }
@ -202,7 +204,7 @@ func (m *msgServer) modifyMessageByUserMessageReceiveOpt(
return true, nil return true, nil
} }
// conversationID := utils.GetConversationIDBySessionType(conversationID, sessionType) // conversationID := utils.GetConversationIDBySessionType(conversationID, sessionType)
singleOpt, err := m.Conversation.GetSingleConversationRecvMsgOpt(ctx, userID, conversationID) singleOpt, err := m.Conversation.GetSingleConversationRecvMsgOpt(ctx, userID, conversationID) // todo local cache
if errs.ErrRecordNotFound.Is(err) { if errs.ErrRecordNotFound.Is(err) {
return true, nil return true, nil
} else if err != nil { } else if err != nil {