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

pull/232/head
Gordon 3 years ago
commit b14b53329c

@ -94,6 +94,7 @@ func (rpc *rpcChat) runCh() {
if err := db.DB.DelMsgBySeqList(msg.UserID, msg.SeqList, msg.OperationID); err != nil {
log.NewError(msg.OperationID, utils.GetSelfFuncName(), "DelMsgBySeqList qrgs: ", msg.UserID, msg.SeqList, msg.OperationID, err.Error())
}
db.DataBases.DelMsgFromCache(msg.SeqList, msg.UserID, msg.OperationID)
}
}
}

@ -313,3 +313,31 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string,
}
return nil
}
func (d *DataBases) DelMsgFromCache(seqList []uint32, uid, operationID string) {
for _, seq := range seqList {
key := messageCache + uid + "_" + strconv.Itoa(int(seq))
result, err := redis.String(d.Exec("GET", key))
if err != nil {
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key)
continue
}
log2.Debug(operationID, utils.GetSelfFuncName(), "del result", result)
var msg pbCommon.MsgData
err = utils.String2Pb(result, &msg)
if err != nil {
log2.NewWarn(operationID, utils.GetSelfFuncName(), "string2Pb failed", msg, err.Error())
continue
}
msg.Status = 4
s, err := utils.Pb2String(&msg)
if err != nil {
log2.NewWarn(operationID, utils.GetSelfFuncName(), "Pb2String failed", msg, err.Error())
continue
}
_, err = d.Exec("SET", key, s, "ex", config.Config.MsgCacheTimeout)
if err != nil {
log2.NewWarn(operationID, utils.GetSelfFuncName(), "redis failed", "args:", key, msg, s)
}
}
}

@ -143,7 +143,10 @@ func Pb2String(pb proto.Message) (string, error) {
EmitDefaults: false,
}
return marshaler.MarshalToString(pb)
}
func String2Pb(s string, pb proto.Message) error {
return proto.Unmarshal([]byte(s), pb)
}
func Map2Pb(m map[string]interface{}) (pb proto.Message, err error) {

Loading…
Cancel
Save