From 39b67358d7bc341ada26fb5107450e86ba7dcbce Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 12 Aug 2019 14:53:00 +0300 Subject: [PATCH] Retry timeout by default --- command.go | 11 ++++------- redis.go | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/command.go b/command.go index c9665d8..e4e13a9 100644 --- a/command.go +++ b/command.go @@ -70,7 +70,6 @@ func cmdString(cmd Cmder, val interface{}) string { } } return s - } func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { @@ -102,13 +101,11 @@ type baseCmd struct { var _ Cmder = (*Cmd)(nil) func (cmd *baseCmd) Name() string { - if len(cmd._args) > 0 { - // Cmd name must be lower cased. - s := internal.ToLower(cmd.stringArg(0)) - cmd._args[0] = s - return s + if len(cmd._args) == 0 { + return "" } - return "" + // Cmd name must be lower cased. + return internal.ToLower(cmd.stringArg(0)) } func (cmd *baseCmd) Args() []interface{} { diff --git a/redis.go b/redis.go index 6058b4a..94698be 100644 --- a/redis.go +++ b/redis.go @@ -268,13 +268,12 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder) error { } } - var retryTimeout bool + retryTimeout := true lastErr = c.withConn(ctx, func(ctx context.Context, cn *pool.Conn) error { err := cn.WithWriter(ctx, c.opt.WriteTimeout, func(wr *proto.Writer) error { return writeCmd(wr, cmd) }) if err != nil { - retryTimeout = true return err }