Skip to content

Commit

Permalink
⏪ Reverting changes to command.go, refactoring cluster client's calls…
Browse files Browse the repository at this point in the history
… to cmdSlot
  • Loading branch information
Jake Gregg committed Feb 1, 2019
1 parent f3804cd commit 67dcdea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 3 additions & 6 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 67dcdea

Please sign in to comment.