redis增加tls支持 (#595)
* redis连接增加支持tls选项 * 优化redis tls config 写法 * redis增加tls支持 * 增加redis tls测试用例,但redis tls local server不支持,测试用例全部NotNil Co-authored-by: liuyi <liuyi@fangyb.com> Co-authored-by: yi.liu <yi.liu@xshoppy.com>
This commit is contained in:
@@ -14,9 +14,10 @@ var (
|
||||
type (
|
||||
// A RedisConf is a redis config.
|
||||
RedisConf struct {
|
||||
Host string
|
||||
Type string `json:",default=node,options=node|cluster"`
|
||||
Pass string `json:",optional"`
|
||||
Host string
|
||||
Type string `json:",default=node,options=node|cluster"`
|
||||
Pass string `json:",optional"`
|
||||
TLSFlag bool `json:",default=false,options=true|false"`
|
||||
}
|
||||
|
||||
// A RedisKeyConf is a redis config with key.
|
||||
@@ -28,6 +29,9 @@ type (
|
||||
|
||||
// NewRedis returns a Redis.
|
||||
func (rc RedisConf) NewRedis() *Redis {
|
||||
if rc.TLSFlag {
|
||||
return NewRedisWithTLS(rc.Host, rc.Type, rc.TLSFlag, rc.Pass)
|
||||
}
|
||||
return NewRedis(rc.Host, rc.Type, rc.Pass)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user