pull/236/head
wenxu12345 3 years ago
parent 8315c61240
commit b2df6e6d41

@ -18,7 +18,7 @@ func (rpc *rpcChat) ClearMsg(_ context.Context, req *pbChat.ClearMsgReq) (*pbCha
return &pbChat.ClearMsgResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
}
log.Debug(req.OperationID, "CleanUpOneUserAllMsgFromRedis args", req.UserID)
err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID)
err := db.DB.CleanUpOneUserAllMsgFromRedis(req.UserID, req.OperationID)
if err != nil {
errMsg := "CleanUpOneUserAllMsgFromRedis failed " + err.Error() + req.OperationID + req.UserID
log.Error(req.OperationID, errMsg)

@ -1193,7 +1193,7 @@ func superGroupIndexGen(groupID string, seqSuffix uint32) string {
return "super_group_" + groupID + ":" + strconv.FormatInt(int64(seqSuffix), 10)
}
func (d *DataBases) CleanUpUserMsgFromMongo(userID string) error {
func (d *DataBases) CleanUpUserMsgFromMongo(userID string, operationID string) error {
ctx := context.Background()
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
maxSeq, err := d.GetUserMaxSeq(userID)
@ -1205,7 +1205,7 @@ func (d *DataBases) CleanUpUserMsgFromMongo(userID string) error {
}
seqUsers := getSeqUserIDList(userID, uint32(maxSeq))
//bson.M{"id":bson.M{"$in":list}}
log.Error(operationID, "getSeqUserIDList", seqUsers)
_, err = c.DeleteMany(ctx, bson.M{"uid": bson.M{"$in": seqUsers}})
if err == mongo.ErrNoDocuments {
return nil

@ -85,10 +85,11 @@ func (d *DataBases) NewSetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid stri
return nil
}
func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string) error {
func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID string) error {
ctx := context.Background()
key := messageCache + userID + "_" + "*"
vals, err := d.rdb.Keys(ctx, key).Result()
log2.Debug(operationID, "vals: ", vals)
if err == redis.ErrNil {
return nil
}

Loading…
Cancel
Save