Skip to content

Commit

Permalink
fix(cache): update field 'Host' to 'Addr'
Browse files Browse the repository at this point in the history
  • Loading branch information
WalleV committed Dec 7, 2021
1 parent 096a1f0 commit dc0d6bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions cache/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
defaultTimeoutConnect = 10000
defaultTimeoutRead = 5000
defaultTimeoutWrite = 5000
defaultHost = "localhost:6379"
defaultAddr = "localhost:6379"
defaultProtocol = "tcp"
defaultRetryThreshold = 5
)
Expand All @@ -44,7 +44,7 @@ type RedisOptions struct {
MaxIdle int
MaxActive int
Protocol string
Host string
Addr string
Password string
DB int
SSLEnabled bool
Expand All @@ -68,7 +68,7 @@ func NewGRedis(opts interface{}) (gr *GRedis) {
toW := time.Millisecond * time.Duration(options.TimeoutWrite)
toI := time.Duration(options.TimeoutIdle) * time.Second
option := &redis.Options{
Addr: options.Host,
Addr: options.Addr,
DB: options.DB,
DialTimeout: toD,
ReadTimeout: toR,
Expand Down Expand Up @@ -124,8 +124,8 @@ func (r *RedisOptions) initDefaults() *RedisOptions {
r.TimeoutWrite = defaultTimeoutWrite
}

if r.Host == "" {
r.Host = defaultHost
if r.Addr == "" {
r.Addr = defaultAddr
}

if r.Protocol == "" {
Expand Down
2 changes: 1 addition & 1 deletion cache/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getTestGRedis() *GRedis {
}

options := RedisOptions{
Host: "127.0.0.1:6379",
Addr: "127.0.0.1:6379",
Password: "",
DB: 1,
}
Expand Down

0 comments on commit dc0d6bc

Please sign in to comment.