Use Redis Options TLSConfig if returned

This commit is contained in:
Juan Calderon-Perez
2023-09-09 21:32:28 -04:00
parent 0e55883f05
commit 89c473aac7

View File

@@ -33,6 +33,11 @@ func New(config ...Config) *Storage {
cfg.Password = options.Password
cfg.Database = options.DB
cfg.Addrs = []string{options.Addr}
// If cfg.TLSConfig is not provided, and options returns one, use it.
if cfg.TLSConfig == nil && options.TLSConfig != nil {
cfg.TLSConfig = options.TLSConfig
}
} else if len(cfg.Addrs) == 0 {
// Fallback to Host and Port values if Addrs is empty
cfg.Addrs = []string{fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)}