|
|
@ -26,7 +26,7 @@ type DataBases struct {
|
|
|
|
mgoSession *mgo.Session
|
|
|
|
mgoSession *mgo.Session
|
|
|
|
redisPool *redis.Pool
|
|
|
|
redisPool *redis.Pool
|
|
|
|
mongoClient *mongo.Client
|
|
|
|
mongoClient *mongo.Client
|
|
|
|
rdb *go_redis.ClusterClient
|
|
|
|
rdb *go_redis.Client
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func key(dbAddress, dbName string) string {
|
|
|
|
func key(dbAddress, dbName string) string {
|
|
|
@ -117,12 +117,17 @@ func init() {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DB.rdb = go_redis.NewClient(&go_redis.Options{
|
|
|
|
DB.rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{
|
|
|
|
Addr: config.Config.Redis.DBAddress,
|
|
|
|
Addrs: []string{config.Config.Redis.DBAddress},
|
|
|
|
Password: config.Config.Redis.DBPassWord, // no password set
|
|
|
|
PoolSize: 100,
|
|
|
|
DB: 0, // use default DB
|
|
|
|
Password: config.Config.Redis.DBPassWord,
|
|
|
|
PoolSize: 100, // 连接池大小
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
//DB.rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{
|
|
|
|
|
|
|
|
// Addrs: []string{config.Config.Redis.DBAddress},
|
|
|
|
|
|
|
|
// PoolSize: 100,
|
|
|
|
|
|
|
|
// Password: config.Config.Redis.DBPassWord,
|
|
|
|
|
|
|
|
//})
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
defer cancel()
|
|
|
|
_, err = DB.rdb.Ping(ctx).Result()
|
|
|
|
_, err = DB.rdb.Ping(ctx).Result()
|
|
|
|