Merge remote-tracking branch 'origin/superGroup' into superGroup

pull/236/head
skiffer-git 2 years ago
commit 1a6a0d3592

@ -128,30 +128,27 @@ func (d *DataBases) GetUserGlobalMsgRecvOpt(userID string) (int, error) {
return utils.StringToInt(result), err return utils.StringToInt(result), err
} }
func (d *DataBases) GetMessageListBySeq(userID string, seqList []uint32, operationID string) (seqMsg []*pbCommon.MsgData, failedSeqList []uint32, errResult error) { func (d *DataBases) GetMessageListBySeq(userID string, seqList []uint32, operationID string) (seqMsg []*pbCommon.MsgData, failedSeqList []uint32, errResult error) {
var keys []string
for _, v := range seqList { for _, v := range seqList {
//MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1 //MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1
key := messageCache + userID + "_" + strconv.Itoa(int(v)) key := messageCache + userID + "_" + strconv.Itoa(int(v))
keys = append(keys, key)
} result, err := d.rdb.Get(context.Background(), key).Result()
result, err := d.rdb.MGet(context.Background(), keys...).Result() if err != nil {
if err != nil { errResult = err
errResult = err failedSeqList = append(failedSeqList, v)
failedSeqList = seqList log2.NewWarn(operationID, "redis get message error:", err.Error(), v)
log2.NewWarn(operationID, "redis get message error:", err.Error(), seqList) } else {
} else {
for _, v := range result {
msg := pbCommon.MsgData{} msg := pbCommon.MsgData{}
err = jsonpb.UnmarshalString(v.(string), &msg) err = jsonpb.UnmarshalString(result, &msg)
if err != nil { if err != nil {
errResult = err errResult = err
failedSeqList = seqList failedSeqList = append(failedSeqList, v)
log2.NewWarn(operationID, "Unmarshal err", result, err.Error()) log2.NewWarn(operationID, "Unmarshal err", result, err.Error())
break
} else { } else {
log2.NewDebug(operationID, "redis get msg is ", msg.String()) log2.NewDebug(operationID, "redis get msg is ", msg.String())
seqMsg = append(seqMsg, &msg) seqMsg = append(seqMsg, &msg)
} }
} }
} }
return seqMsg, failedSeqList, errResult return seqMsg, failedSeqList, errResult

Loading…
Cancel
Save