mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 03:05:05 +08:00
enhance: add sentinel auth config for redis (#3348)
This commit is contained in:
parent
fbd266fad0
commit
9b48da459e
@ -44,23 +44,25 @@ func init() {
|
||||
func New(config *gredis.Config) *Redis {
|
||||
fillWithDefaultConfiguration(config)
|
||||
opts := &redis.UniversalOptions{
|
||||
Addrs: gstr.SplitAndTrim(config.Address, ","),
|
||||
Username: config.User,
|
||||
Password: config.Pass,
|
||||
DB: config.Db,
|
||||
MaxRetries: defaultMaxRetries,
|
||||
PoolSize: config.MaxActive,
|
||||
MinIdleConns: config.MinIdle,
|
||||
MaxIdleConns: config.MaxIdle,
|
||||
ConnMaxLifetime: config.MaxConnLifetime,
|
||||
ConnMaxIdleTime: config.IdleTimeout,
|
||||
PoolTimeout: config.WaitTimeout,
|
||||
DialTimeout: config.DialTimeout,
|
||||
ReadTimeout: config.ReadTimeout,
|
||||
WriteTimeout: config.WriteTimeout,
|
||||
MasterName: config.MasterName,
|
||||
TLSConfig: config.TLSConfig,
|
||||
Protocol: config.Protocol,
|
||||
Addrs: gstr.SplitAndTrim(config.Address, ","),
|
||||
Username: config.User,
|
||||
Password: config.Pass,
|
||||
SentinelUsername: config.SentinelUser,
|
||||
SentinelPassword: config.SentinelPass,
|
||||
DB: config.Db,
|
||||
MaxRetries: defaultMaxRetries,
|
||||
PoolSize: config.MaxActive,
|
||||
MinIdleConns: config.MinIdle,
|
||||
MaxIdleConns: config.MaxIdle,
|
||||
ConnMaxLifetime: config.MaxConnLifetime,
|
||||
ConnMaxIdleTime: config.IdleTimeout,
|
||||
PoolTimeout: config.WaitTimeout,
|
||||
DialTimeout: config.DialTimeout,
|
||||
ReadTimeout: config.ReadTimeout,
|
||||
WriteTimeout: config.WriteTimeout,
|
||||
MasterName: config.MasterName,
|
||||
TLSConfig: config.TLSConfig,
|
||||
Protocol: config.Protocol,
|
||||
}
|
||||
|
||||
var client redis.UniversalClient
|
||||
|
@ -25,6 +25,8 @@ type Config struct {
|
||||
Db int `json:"db"` // Redis db.
|
||||
User string `json:"user"` // Username for AUTH.
|
||||
Pass string `json:"pass"` // Password for AUTH.
|
||||
SentinelUser string `json:"sentinel_user"` // Username for sentinel AUTH.
|
||||
SentinelPass string `json:"sentinel_pass"` // Password for sentinel AUTH.
|
||||
MinIdle int `json:"minIdle"` // Minimum number of connections allowed to be idle (default is 0)
|
||||
MaxIdle int `json:"maxIdle"` // Maximum number of connections allowed to be idle (default is 10)
|
||||
MaxActive int `json:"maxActive"` // Maximum number of connections limit (default is 0 means no limit).
|
||||
|
Loading…
x
Reference in New Issue
Block a user