mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-07 01:14:24 +08:00
msg cache
This commit is contained in:
parent
94e6380485
commit
49cd31fd41
@ -10,8 +10,6 @@ import (
|
|||||||
"github.com/garyburd/redigo/redis"
|
"github.com/garyburd/redigo/redis"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"runtime"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string, currentMaxSeq uint64) error {
|
func (d *DataBases) BatchInsertChat2DB(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string, currentMaxSeq uint64) error {
|
||||||
@ -120,23 +118,22 @@ func (d *DataBases) BatchInsertChat2Cache(userID string, msgList []*pbMsg.MsgDat
|
|||||||
return utils.Wrap(d.SetUserMaxSeq(userID, uint64(currentMaxSeq)), ""), lastMaxSeq
|
return utils.Wrap(d.SetUserMaxSeq(userID, uint64(currentMaxSeq)), ""), lastMaxSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) BatchInsertChatBoth(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) error {
|
//func (d *DataBases) BatchInsertChatBoth(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) (error, uint64) {
|
||||||
err, lastMaxSeq := d.BatchInsertChat2Cache(userID, msgList, operationID)
|
// err, lastMaxSeq := d.BatchInsertChat2Cache(userID, msgList, operationID)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error(operationID, "BatchInsertChat2Cache failed ", err.Error(), userID, len(msgList))
|
// log.Error(operationID, "BatchInsertChat2Cache failed ", err.Error(), userID, len(msgList))
|
||||||
return err
|
// return err, 0
|
||||||
}
|
// }
|
||||||
for {
|
// for {
|
||||||
if runtime.NumGoroutine() > 50000 {
|
// if runtime.NumGoroutine() > 50000 {
|
||||||
log.NewWarn(operationID, "too many NumGoroutine ", runtime.NumGoroutine())
|
// log.NewWarn(operationID, "too many NumGoroutine ", runtime.NumGoroutine())
|
||||||
time.Sleep(10 * time.Millisecond)
|
// time.Sleep(10 * time.Millisecond)
|
||||||
} else {
|
// } else {
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
go d.BatchInsertChat2DB(userID, msgList, operationID, lastMaxSeq)
|
// return nil, lastMaxSeq
|
||||||
return nil
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DataBases) BatchInsertChat(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) error {
|
func (d *DataBases) BatchInsertChat(userID string, msgList []*pbMsg.MsgDataToMQ, operationID string) error {
|
||||||
newTime := getCurrentTimestampByMill()
|
newTime := getCurrentTimestampByMill()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user