redis配置默认值
This commit is contained in:
parent
9b7f627b0f
commit
8de9252ae5
|
|
@ -22,14 +22,20 @@ type Config struct {
|
||||||
// Init init
|
// Init init
|
||||||
func Init(opts *Config) error {
|
func Init(opts *Config) error {
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = &Config{
|
opts = &Config{}
|
||||||
Host: "127.0.0.1:6379",
|
|
||||||
Password: "",
|
|
||||||
Database: 0,
|
|
||||||
MaxIdle: 10,
|
|
||||||
MaxActive: 100,
|
|
||||||
IdleTimeout: 600,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.Host == "" {
|
||||||
|
opts.Host = "127.0.0.1:6379"
|
||||||
|
}
|
||||||
|
if opts.MaxIdle == 0 {
|
||||||
|
opts.MaxIdle = 1
|
||||||
|
}
|
||||||
|
if opts.MaxActive == 0 {
|
||||||
|
opts.MaxActive = 10
|
||||||
|
}
|
||||||
|
if opts.IdleTimeout == 0 {
|
||||||
|
opts.IdleTimeout = 600
|
||||||
}
|
}
|
||||||
|
|
||||||
pool = &redigo.Pool{
|
pool = &redigo.Pool{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue