mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
redis replace to go_redis
This commit is contained in:
parent
eef47017a3
commit
f96e12a8b3
@ -9,7 +9,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
@ -117,7 +117,7 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
|
||||
log.NewDebug(operationID, uid, platformID, "kick old conn")
|
||||
ws.sendKickMsg(oldConn, newConn)
|
||||
m, err := db.DB.GetTokenMapByUidPid(uid, constant.PlatformIDToName(platformID))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
if err != nil && err != go_redis.Nil {
|
||||
log.NewError(operationID, "get token from redis err", err.Error(), uid)
|
||||
return
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package msg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
@ -15,7 +15,7 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *open_im_sdk.GetMaxAnd
|
||||
m := make(map[string]*open_im_sdk.MaxAndMinSeq)
|
||||
//seq, err := model.GetBiggestSeqFromReceive(in.UserID)
|
||||
maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID)
|
||||
minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
|
||||
//minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
|
||||
if err1 == nil {
|
||||
resp.MaxSeq = uint32(maxSeq)
|
||||
for _, v := range in.GroupIDList {
|
||||
@ -25,22 +25,22 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *open_im_sdk.GetMaxAnd
|
||||
m[v] = x
|
||||
}
|
||||
resp.GroupMaxAndMinSeq = m
|
||||
} else if err1 == redis.ErrNil {
|
||||
} else if err1 == go_redis.Nil {
|
||||
resp.MaxSeq = 0
|
||||
} else {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error())
|
||||
resp.ErrCode = 200
|
||||
resp.ErrMsg = "redis get err"
|
||||
}
|
||||
if err2 == nil {
|
||||
resp.MinSeq = uint32(minSeq)
|
||||
} else if err2 == redis.ErrNil {
|
||||
resp.MinSeq = 0
|
||||
} else {
|
||||
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error())
|
||||
resp.ErrCode = 201
|
||||
resp.ErrMsg = "redis get err"
|
||||
}
|
||||
//if err2 == nil {
|
||||
// resp.MinSeq = uint32(minSeq)
|
||||
//} else if err2 == redis.ErrNil {
|
||||
// resp.MinSeq = 0
|
||||
//} else {
|
||||
// log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error())
|
||||
// resp.ErrCode = 201
|
||||
// resp.ErrMsg = "redis get err"
|
||||
//}
|
||||
return resp, nil
|
||||
}
|
||||
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {
|
||||
@ -50,7 +50,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
||||
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
||||
redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(in.UserID, in.SeqList, in.OperationID)
|
||||
if err != nil {
|
||||
if err != redis.ErrNil {
|
||||
if err != go_redis.Nil {
|
||||
log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList)
|
||||
} else {
|
||||
log.Debug(in.OperationID, "get message from redis is nil", failedSeqList)
|
||||
@ -72,7 +72,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
||||
x := new(open_im_sdk.MsgDataList)
|
||||
redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, in.OperationID)
|
||||
if err != nil {
|
||||
if err != redis.ErrNil {
|
||||
if err != go_redis.Nil {
|
||||
log.Error(in.OperationID, "get message from redis exception", err.Error(), failedSeqList)
|
||||
} else {
|
||||
log.Debug(in.OperationID, "get message from redis is nil", failedSeqList)
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
@ -464,7 +464,7 @@ func returnMsg(replay *pbChat.SendMsgResp, pb *pbChat.SendMsgReq, errCode int32,
|
||||
func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType int, pb *pbChat.SendMsgReq) bool {
|
||||
conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType)
|
||||
opt, err := db.DB.GetSingleConversationRecvMsgOpt(userID, conversationID)
|
||||
if err != nil && err != redis.ErrNil {
|
||||
if err != nil && err != go_redis.Nil {
|
||||
log.NewError(pb.OperationID, "GetSingleConversationMsgOpt from redis err", conversationID, pb.String(), err.Error())
|
||||
return true
|
||||
}
|
||||
@ -487,7 +487,7 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i
|
||||
func modifyMessageByUserMessageReceiveOptoptimization(userID, sourceID string, sessionType int, operationID string, options *map[string]bool) bool {
|
||||
conversationID := utils.GetConversationIDBySessionType(sourceID, sessionType)
|
||||
opt, err := db.DB.GetSingleConversationRecvMsgOpt(userID, conversationID)
|
||||
if err != nil && err != redis.ErrNil {
|
||||
if err != nil && err != go_redis.Nil {
|
||||
log.NewError(operationID, "GetSingleConversationMsgOpt from redis err", userID, conversationID, err.Error())
|
||||
return true
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -112,7 +112,7 @@ func (d *DataBases) BatchInsertChat2Cache(userID string, msgList []*pbMsg.MsgDat
|
||||
currentMaxSeq, err := d.GetUserMaxSeq(userID)
|
||||
if err == nil {
|
||||
|
||||
} else if err == redis.ErrNil {
|
||||
} else if err == go_redis.Nil {
|
||||
currentMaxSeq = 0
|
||||
} else {
|
||||
return utils.Wrap(err, ""), 0
|
||||
@ -161,7 +161,7 @@ func (d *DataBases) BatchInsertChat(userID string, msgList []*pbMsg.MsgDataToMQ,
|
||||
currentMaxSeq, err := d.GetUserMaxSeq(userID)
|
||||
if err == nil {
|
||||
|
||||
} else if err == redis.ErrNil {
|
||||
} else if err == go_redis.Nil {
|
||||
isInit = true
|
||||
currentMaxSeq = 0
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
go_redis "github.com/go-redis/redis/v8"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"time"
|
||||
)
|
||||
@ -39,7 +39,7 @@ func BuildClaims(uid, platform string, ttl int64) Claims {
|
||||
|
||||
func DeleteToken(userID string, platformID int) error {
|
||||
m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
if err != nil && err != go_redis.Nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
var deleteTokenKey []string
|
||||
@ -65,7 +65,7 @@ func CreateToken(userID string, platformID int) (string, int64, error) {
|
||||
}
|
||||
//remove Invalid token
|
||||
m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID))
|
||||
if err != nil && err != redis.ErrNil {
|
||||
if err != nil && err != go_redis.Nil {
|
||||
return "", 0, err
|
||||
}
|
||||
var deleteTokenKey []string
|
||||
|
Loading…
x
Reference in New Issue
Block a user