From 67dcdea95a901d9126cbb1ba74140169024c07a3 Mon Sep 17 00:00:00 2001 From: Jake Gregg Date: Fri, 1 Feb 2019 09:12:20 -0800 Subject: [PATCH] :rewind: Reverting changes to command.go, refactoring cluster client's calls to cmdSlot --- cluster.go | 9 +++------ command.go | 5 ----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cluster.go b/cluster.go index ed68a421..09454f43 100644 --- a/cluster.go +++ b/cluster.go @@ -767,11 +767,8 @@ func cmdSlot(cmd Cmder, pos int) int { if pos == 0 { return hashtag.RandomSlot() } - val, ok := cmd.Args()[pos].(int) - if ok { - return val - } - return hashtag.Slot(cmd.stringArg(pos)) + firstKey := cmd.stringArg(pos) + return hashtag.Slot(firstKey) } func (c *ClusterClient) cmdSlot(cmd Cmder) int { @@ -791,7 +788,7 @@ func (c *ClusterClient) cmdSlotAndNode(cmd Cmder) (int, *clusterNode, error) { } cmdInfo := c.cmdInfo(cmd.Name()) - slot := cmdSlot(cmd, cmdFirstKeyPos(cmd, cmdInfo)) + slot := c.cmdSlot(cmd) if c.opt.ReadOnly && cmdInfo != nil && cmdInfo.ReadOnly { if c.opt.RouteByLatency { diff --git a/command.go b/command.go index a70d09ca..cb4f94b1 100644 --- a/command.go +++ b/command.go @@ -74,11 +74,6 @@ func cmdString(cmd Cmder, val interface{}) string { func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { switch cmd.Name() { - case "cluster": - switch cmd.stringArg(1) { - case "getkeysinslot": - return 2 - } case "eval", "evalsha": if cmd.stringArg(2) != "0" { return 3