From 5c3a43f602252be9bb8ae638bc0dbd400039aca3 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 18 Aug 2022 11:14:38 +0800 Subject: [PATCH] fix bug --- pkg/common/db/RedisModel.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/common/db/RedisModel.go b/pkg/common/db/RedisModel.go index 8ad30f878..1f81fc3ef 100644 --- a/pkg/common/db/RedisModel.go +++ b/pkg/common/db/RedisModel.go @@ -11,11 +11,12 @@ import ( "context" "errors" "fmt" + "strconv" + "time" + go_redis "github.com/go-redis/redis/v8" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" - "strconv" - "time" ) const ( @@ -230,16 +231,14 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string, } func (d *DataBases) DeleteMessageFromCache(msgList []*pbChat.MsgDataToMQ, uid string, operationID string) error { ctx := context.Background() - var keys []string for _, msg := range msgList { key := messageCache + uid + "_" + strconv.Itoa(int(msg.MsgData.Seq)) - keys = append(keys, key) - } - err := d.RDB.Del(ctx, keys...).Err() - if err != nil { - log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", keys, uid, err.Error(), msgList) + err := d.RDB.Del(ctx, key).Err() + if err != nil { + log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key, uid, err.Error(), msgList) + } } - return err + return nil } func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID string) error {