|
|
@ -10,9 +10,7 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
go_redis "github.com/go-redis/redis/v8"
|
|
|
|
go_redis "github.com/go-redis/redis/v8"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
|
|
// "context"
|
|
|
|
|
|
|
|
// "fmt"
|
|
|
|
|
|
|
|
"github.com/garyburd/redigo/redis"
|
|
|
|
|
|
|
|
"gopkg.in/mgo.v2"
|
|
|
|
"gopkg.in/mgo.v2"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +26,7 @@ var DB DataBases
|
|
|
|
type DataBases struct {
|
|
|
|
type DataBases struct {
|
|
|
|
MysqlDB mysqlDB
|
|
|
|
MysqlDB mysqlDB
|
|
|
|
mgoSession *mgo.Session
|
|
|
|
mgoSession *mgo.Session
|
|
|
|
redisPool *redis.Pool
|
|
|
|
//redisPool *redis.Pool
|
|
|
|
mongoClient *mongo.Client
|
|
|
|
mongoClient *mongo.Client
|
|
|
|
rdb *go_redis.Client
|
|
|
|
rdb *go_redis.Client
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -98,22 +96,22 @@ func init() {
|
|
|
|
DB.mongoClient = mongoClient
|
|
|
|
DB.mongoClient = mongoClient
|
|
|
|
|
|
|
|
|
|
|
|
// redis pool init
|
|
|
|
// redis pool init
|
|
|
|
DB.redisPool = &redis.Pool{
|
|
|
|
//DB.redisPool = &redis.Pool{
|
|
|
|
MaxIdle: config.Config.Redis.DBMaxIdle,
|
|
|
|
// MaxIdle: config.Config.Redis.DBMaxIdle,
|
|
|
|
MaxActive: config.Config.Redis.DBMaxActive,
|
|
|
|
// MaxActive: config.Config.Redis.DBMaxActive,
|
|
|
|
IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second,
|
|
|
|
// IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second,
|
|
|
|
Dial: func() (redis.Conn, error) {
|
|
|
|
// Dial: func() (redis.Conn, error) {
|
|
|
|
return redis.Dial(
|
|
|
|
// return redis.Dial(
|
|
|
|
"tcp",
|
|
|
|
// "tcp",
|
|
|
|
config.Config.Redis.DBAddress,
|
|
|
|
// config.Config.Redis.DBAddress,
|
|
|
|
redis.DialReadTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
// redis.DialReadTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
// redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
// redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond),
|
|
|
|
redis.DialDatabase(0),
|
|
|
|
// redis.DialDatabase(0),
|
|
|
|
redis.DialPassword(config.Config.Redis.DBPassWord),
|
|
|
|
// redis.DialPassword(config.Config.Redis.DBPassWord),
|
|
|
|
)
|
|
|
|
// )
|
|
|
|
},
|
|
|
|
// },
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
DB.rdb = go_redis.NewClient(&go_redis.Options{
|
|
|
|
DB.rdb = go_redis.NewClient(&go_redis.Options{
|
|
|
|
Addr: config.Config.Redis.DBAddress,
|
|
|
|
Addr: config.Config.Redis.DBAddress,
|
|
|
|
Password: config.Config.Redis.DBPassWord, // no password set
|
|
|
|
Password: config.Config.Redis.DBPassWord, // no password set
|
|
|
|