Skip to content

Commit

Permalink
Simplify cmdInfo check.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Dec 9, 2016
1 parent 4ce47a0 commit 420337d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cluster.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package redis

import (
"fmt"
"math/rand"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -367,14 +366,12 @@ func (c *ClusterClient) state() *clusterState {
func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *clusterNode, error) {
cmdInfo := c.cmds[cmd.arg(0)]
firstKey := cmd.arg(cmdFirstKeyPos(cmd, cmdInfo))
if firstKey == "" {
if firstKey == "" || cmdInfo == nil {
node, err := c.nodes.Random()
return -1, node, err
}
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 c.opt.RouteByLatency {
node, err := state.slotClosestNode(slot)
Expand Down

0 comments on commit 420337d

Please sign in to comment.