mirror of https://github.com/go-redis/redis.git
Simplify cmdInfo check.
This commit is contained in:
parent
4ce47a025f
commit
420337dc4a
|
@ -1,7 +1,6 @@
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -367,14 +366,12 @@ func (c *ClusterClient) state() *clusterState {
|
||||||
func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *clusterNode, error) {
|
func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *clusterNode, error) {
|
||||||
cmdInfo := c.cmds[cmd.arg(0)]
|
cmdInfo := c.cmds[cmd.arg(0)]
|
||||||
firstKey := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo))
|
firstKey := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo))
|
||||||
if firstKey == "" {
|
if firstKey == "" || cmdInfo == nil {
|
||||||
node, err := c.nodes.Random()
|
node, err := c.nodes.Random()
|
||||||
return -1, node, err
|
return -1, node, err
|
||||||
}
|
}
|
||||||
slot := hashtag.Slot(firstKey)
|
slot := hashtag.Slot(firstKey)
|
||||||
if cmdInfo == nil {
|
|
||||||
return -1, nil, internal.RedisError(fmt.Sprintf("cmdInfo of %s is nil", cmd.arg(0)))
|
|
||||||
}
|
|
||||||
if cmdInfo.ReadOnly && c.opt.ReadOnly {
|
if cmdInfo.ReadOnly && c.opt.ReadOnly {
|
||||||
if c.opt.RouteByLatency {
|
if c.opt.RouteByLatency {
|
||||||
node, err := state.slotClosestNode(slot)
|
node, err := state.slotClosestNode(slot)
|
||||||
|
|
Loading…
Reference in New Issue