From 4315d9dfbb1c02fd8936abbe120b46418e28c27d Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 15 Jun 2022 16:35:24 +0800 Subject: [PATCH] redis replace to go_redis --- pkg/common/db/model.go | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 6d1660807..2418e7658 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -10,9 +10,7 @@ import ( "fmt" go_redis "github.com/go-redis/redis/v8" "go.mongodb.org/mongo-driver/mongo/options" - // "context" - // "fmt" - "github.com/garyburd/redigo/redis" + "gopkg.in/mgo.v2" "time" @@ -26,9 +24,9 @@ import ( var DB DataBases type DataBases struct { - MysqlDB mysqlDB - mgoSession *mgo.Session - redisPool *redis.Pool + MysqlDB mysqlDB + mgoSession *mgo.Session + //redisPool *redis.Pool mongoClient *mongo.Client rdb *go_redis.Client } @@ -98,22 +96,22 @@ func init() { DB.mongoClient = mongoClient // redis pool init - DB.redisPool = &redis.Pool{ - MaxIdle: config.Config.Redis.DBMaxIdle, - MaxActive: config.Config.Redis.DBMaxActive, - IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second, - Dial: func() (redis.Conn, error) { - return redis.Dial( - "tcp", - config.Config.Redis.DBAddress, - redis.DialReadTimeout(time.Duration(1000)*time.Millisecond), - redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond), - redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond), - redis.DialDatabase(0), - redis.DialPassword(config.Config.Redis.DBPassWord), - ) - }, - } + //DB.redisPool = &redis.Pool{ + // MaxIdle: config.Config.Redis.DBMaxIdle, + // MaxActive: config.Config.Redis.DBMaxActive, + // IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second, + // Dial: func() (redis.Conn, error) { + // return redis.Dial( + // "tcp", + // config.Config.Redis.DBAddress, + // redis.DialReadTimeout(time.Duration(1000)*time.Millisecond), + // redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond), + // redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond), + // redis.DialDatabase(0), + // redis.DialPassword(config.Config.Redis.DBPassWord), + // ) + // }, + //} DB.rdb = go_redis.NewClient(&go_redis.Options{ Addr: config.Config.Redis.DBAddress, Password: config.Config.Redis.DBPassWord, // no password set