优化 redis 配置方式
This commit is contained in:
@@ -36,14 +36,19 @@ func NewAutoConfig(src string) (KVConfig, error) {
|
|||||||
return NewConfigMemory(parse.Path)
|
return NewConfigMemory(parse.Path)
|
||||||
case "redis":
|
case "redis":
|
||||||
query := parse.Query()
|
query := parse.Query()
|
||||||
addr := query.Get("addr")
|
|
||||||
pass := query.Get("pass")
|
pass := query.Get("pass")
|
||||||
|
if pass == "" {
|
||||||
|
pass = query.Get("password")
|
||||||
|
}
|
||||||
db := query.Get("db")
|
db := query.Get("db")
|
||||||
|
if db == "" {
|
||||||
|
db = "0"
|
||||||
|
}
|
||||||
dbi, err := strconv.Atoi(db)
|
dbi, err := strconv.Atoi(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return NewConfigRedis(context.Background(), addr, pass, dbi)
|
return NewConfigRedis(context.Background(), parse.Host, pass, dbi)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported scheme: %s", parse.Scheme)
|
return nil, fmt.Errorf("unsupported scheme: %s", parse.Scheme)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user