remove cache message from redis

This commit is contained in:
Gordon
2022-07-27 12:15:32 +08:00
parent 5a626e9dab
commit bbc62ef907
2 changed files with 19 additions and 1 deletions
+13
View File
@@ -221,6 +221,19 @@ func (d *DataBases) SetMessageToCache(msgList []*pbChat.MsgDataToMQ, uid string,
_, err := pipe.Exec(ctx)
return err
}
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)
}
return err
}
func (d *DataBases) CleanUpOneUserAllMsgFromRedis(userID string, operationID string) error {
ctx := context.Background()