mirror of https://github.com/go-redis/redis.git
⏪ Reverting changes to command.go, refactoring cluster client's calls to cmdSlot
This commit is contained in:
parent
f3804cd0b7
commit
67dcdea95a
|
@ -767,11 +767,8 @@ func cmdSlot(cmd Cmder, pos int) int {
|
||||||
if pos == 0 {
|
if pos == 0 {
|
||||||
return hashtag.RandomSlot()
|
return hashtag.RandomSlot()
|
||||||
}
|
}
|
||||||
val, ok := cmd.Args()[pos].(int)
|
firstKey := cmd.stringArg(pos)
|
||||||
if ok {
|
return hashtag.Slot(firstKey)
|
||||||
return val
|
|
||||||
}
|
|
||||||
return hashtag.Slot(cmd.stringArg(pos))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClusterClient) cmdSlot(cmd Cmder) int {
|
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())
|
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.ReadOnly && cmdInfo != nil && cmdInfo.ReadOnly {
|
||||||
if c.opt.RouteByLatency {
|
if c.opt.RouteByLatency {
|
||||||
|
|
|
@ -74,11 +74,6 @@ func cmdString(cmd Cmder, val interface{}) string {
|
||||||
|
|
||||||
func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int {
|
func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int {
|
||||||
switch cmd.Name() {
|
switch cmd.Name() {
|
||||||
case "cluster":
|
|
||||||
switch cmd.stringArg(1) {
|
|
||||||
case "getkeysinslot":
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
case "eval", "evalsha":
|
case "eval", "evalsha":
|
||||||
if cmd.stringArg(2) != "0" {
|
if cmd.stringArg(2) != "0" {
|
||||||
return 3
|
return 3
|
||||||
|
|
Loading…
Reference in New Issue