|
|
@ -28,7 +28,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.UniversalClient
|
|
|
|
rdb *go_redis.ClusterClient
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type RedisClient struct {
|
|
|
|
type RedisClient struct {
|
|
|
@ -130,18 +130,19 @@ func init() {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
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 {
|
|
|
|
func createMongoIndex(client *mongo.Client, collection string, isUnique bool, keys ...string) error {
|
|
|
|