maxlefttime

This commit is contained in:
lingxin 2026-01-30 21:17:27 +08:00
parent 36279cbf5b
commit cc44b0ba9c
2 changed files with 8 additions and 5 deletions

View File

@ -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"
@ -136,8 +137,9 @@ func InitDB(env string, conf DbConfig) {
panic(err) panic(err)
} }
// 设置连接池参数 // 设置连接池参数
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
@ -161,8 +163,9 @@ func InitDB(env string, conf DbConfig) {
panic(err) panic(err)
} }
// 设置连接池参数 // 设置连接池参数
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

View File

@ -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 {