A new User property has been added to the RedisConf object. (#4559)

This commit is contained in:
xujb
2025-01-22 23:28:14 +08:00
committed by GitHub
parent 00e0db5def
commit 37b54d1fc7
2 changed files with 15 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ type (
RedisConf struct {
Host string
Type string `json:",default=node,options=node|cluster"`
User string `json:",optional"`
Pass string `json:",optional"`
Tls bool `json:",optional"`
NonBlock bool `json:",default=true"`
@@ -40,6 +41,9 @@ func (rc RedisConf) NewRedis() *Redis {
if rc.Type == ClusterType {
opts = append(opts, Cluster())
}
if len(rc.User) > 0 {
opts = append(opts, WithUser(rc.User))
}
if len(rc.Pass) > 0 {
opts = append(opts, WithPass(rc.Pass))
}