From aeca8024f73dc3c487542d2db55d9377d7e1ccb3 Mon Sep 17 00:00:00 2001 From: ericjwang Date: Tue, 2 Jul 2019 22:56:38 +0800 Subject: [PATCH 1/2] fix redis option order --- pkg/cache/redis/pool.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/cache/redis/pool.go b/pkg/cache/redis/pool.go index 23a549d62..22d5ec5a6 100644 --- a/pkg/cache/redis/pool.go +++ b/pkg/cache/redis/pool.go @@ -61,18 +61,16 @@ func NewPool(c *Config, options ...DialOption) (p *Pool) { if c.DialTimeout <= 0 || c.ReadTimeout <= 0 || c.WriteTimeout <= 0 { panic("must config redis timeout") } - p1 := pool.NewSlice(c.Config) + var ops []DialOption cnop := DialConnectTimeout(time.Duration(c.DialTimeout)) - options = append(options, cnop) rdop := DialReadTimeout(time.Duration(c.ReadTimeout)) - options = append(options, rdop) wrop := DialWriteTimeout(time.Duration(c.WriteTimeout)) - options = append(options, wrop) auop := DialPassword(c.Auth) - options = append(options, auop) - // new pool + ops = append(ops, cnop, rdop, wrop, auop) + ops = append(ops, options...) + p1 := pool.NewSlice(c.Config) p1.New = func(ctx context.Context) (io.Closer, error) { - conn, err := Dial(c.Proto, c.Addr, options...) + conn, err := Dial(c.Proto, c.Addr, ops...) if err != nil { return nil, err } From 855cca78a5a1f200fc72f2504dec17d7d481e096 Mon Sep 17 00:00:00 2001 From: ericjwang Date: Wed, 3 Jul 2019 00:06:20 +0800 Subject: [PATCH 2/2] fix redis option order --- pkg/cache/redis/pool.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/cache/redis/pool.go b/pkg/cache/redis/pool.go index 22d5ec5a6..9ca76e541 100644 --- a/pkg/cache/redis/pool.go +++ b/pkg/cache/redis/pool.go @@ -61,12 +61,12 @@ func NewPool(c *Config, options ...DialOption) (p *Pool) { if c.DialTimeout <= 0 || c.ReadTimeout <= 0 || c.WriteTimeout <= 0 { panic("must config redis timeout") } - var ops []DialOption - cnop := DialConnectTimeout(time.Duration(c.DialTimeout)) - rdop := DialReadTimeout(time.Duration(c.ReadTimeout)) - wrop := DialWriteTimeout(time.Duration(c.WriteTimeout)) - auop := DialPassword(c.Auth) - ops = append(ops, cnop, rdop, wrop, auop) + ops := []DialOption{ + DialConnectTimeout(time.Duration(c.DialTimeout)), + DialReadTimeout(time.Duration(c.ReadTimeout)), + DialWriteTimeout(time.Duration(c.WriteTimeout)), + DialPassword(c.Auth), + } ops = append(ops, options...) p1 := pool.NewSlice(c.Config) p1.New = func(ctx context.Context) (io.Closer, error) {