maxlefttime
This commit is contained in:
parent
36279cbf5b
commit
cc44b0ba9c
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.listensoft.net/tool/lxutils/lxlog"
|
"git.listensoft.net/tool/lxutils/lxlog"
|
||||||
"git.listensoft.net/tool/lxutils/lxzap"
|
"git.listensoft.net/tool/lxutils/lxzap"
|
||||||
@ -138,6 +139,7 @@ func InitDB(env string, conf DbConfig) {
|
|||||||
// 设置连接池参数
|
// 设置连接池参数
|
||||||
sqlDB.SetMaxIdleConns(conf.MaxIdleConns) // 设置最大空闲连接数为10
|
sqlDB.SetMaxIdleConns(conf.MaxIdleConns) // 设置最大空闲连接数为10
|
||||||
sqlDB.SetMaxOpenConns(conf.MaxOpenConns) // 设置最大打开连接数为100
|
sqlDB.SetMaxOpenConns(conf.MaxOpenConns) // 设置最大打开连接数为100
|
||||||
|
sqlDB.SetConnMaxLifetime(100 * time.Second) // 设置最大打开连接数为100
|
||||||
}
|
}
|
||||||
|
|
||||||
DBS[conf.Name] = db
|
DBS[conf.Name] = db
|
||||||
@ -163,6 +165,7 @@ func InitDB(env string, conf DbConfig) {
|
|||||||
// 设置连接池参数
|
// 设置连接池参数
|
||||||
sqlDB.SetMaxIdleConns(conf.MaxIdleConns) // 设置最大空闲连接数为10
|
sqlDB.SetMaxIdleConns(conf.MaxIdleConns) // 设置最大空闲连接数为10
|
||||||
sqlDB.SetMaxOpenConns(conf.MaxOpenConns) // 设置最大打开连接数为100
|
sqlDB.SetMaxOpenConns(conf.MaxOpenConns) // 设置最大打开连接数为100
|
||||||
|
sqlDB.SetConnMaxLifetime(100 * time.Second) // 设置最大打开连接数为100
|
||||||
}
|
}
|
||||||
|
|
||||||
DBS[conf.Name] = db
|
DBS[conf.Name] = db
|
||||||
|
|||||||
@ -28,7 +28,7 @@ func InitRedis(conf RedisConfig) {
|
|||||||
MaxIdle: conf.MaxIdle,
|
MaxIdle: conf.MaxIdle,
|
||||||
MaxActive: conf.MaxActive,
|
MaxActive: conf.MaxActive,
|
||||||
IdleTimeout: 240 * time.Second,
|
IdleTimeout: 240 * time.Second,
|
||||||
Wait: true,
|
Wait: false,
|
||||||
Dial: func() (redis.Conn, error) {
|
Dial: func() (redis.Conn, error) {
|
||||||
c, err := redis.Dial("tcp", conf.URL, redis.DialPassword(conf.Password))
|
c, err := redis.Dial("tcp", conf.URL, redis.DialPassword(conf.Password))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user