From 28721c7d20a562e2f4c74e6535b29e18201262e6 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 16 Jun 2022 15:34:58 +0800 Subject: [PATCH] add global recv opt --- pkg/common/db/model.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index b4b77ecc2..bc8af133d 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -28,7 +28,7 @@ type DataBases struct { mgoSession *mgo.Session //redisPool *redis.Pool mongoClient *mongo.Client - rdb *go_redis.ClusterClient + rdb go_redis.UniversalClient } type RedisClient struct { @@ -130,19 +130,18 @@ func init() { if err != nil { panic(err.Error()) } + } else { + DB.rdb = go_redis.NewClient(&go_redis.Options{ + Addr: config.Config.Redis.DBAddress, + Password: config.Config.Redis.DBPassWord, // no password set + DB: 0, // use default DB + PoolSize: 100, // 连接池大小 + }) + _, err = DB.rdb.Ping(ctx).Result() + if err != nil { + panic(err.Error()) + } } - //} else { - // DB.rdb = go_redis.NewClient(&go_redis.Options{ - // Addr: config.Config.Redis.DBAddress, - // Password: config.Config.Redis.DBPassWord, // no password set - // DB: 0, // use default DB - // PoolSize: 100, // 连接池大小 - // }) - // _, err = DB.rdb.Ping(ctx).Result() - // if err != nil { - // panic(err.Error()) - // } - //} } func createMongoIndex(client *mongo.Client, collection string, isUnique bool, keys ...string) error {