Skip to content

Commit fffa489

Browse files
committed
fix(txpipeline): extract only keyed cmds from all cmds
1 parent fd2f704 commit fffa489

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

osscluster.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,8 +1521,8 @@ func (c *ClusterClient) processTxPipeline(ctx context.Context, cmds []Cmder) err
15211521

15221522
cmdsMap := map[int][]Cmder{}
15231523
slot := -1
1524-
// split keyed and keyless commands
1525-
keyedCmds, _ := c.keyedAndKeyessCmds(cmds)
1524+
// get only the keyed commands
1525+
keyedCmds := c.keyedCmds(cmds)
15261526
if len(keyedCmds) == 0 {
15271527
// no keyed commands try random slot
15281528
slot = hashtag.RandomSlot()
@@ -1600,17 +1600,17 @@ func (c *ClusterClient) mapCmdsBySlot(cmds []Cmder) map[int][]Cmder {
16001600
}
16011601
return cmdsMap
16021602
}
1603-
func (c *ClusterClient) keyedAndKeyessCmds(cmds []Cmder) ([]Cmder, []Cmder) {
1603+
1604+
// keyedCmds returns all the keyed commands from the cmds slice
1605+
// it determines keyed commands by checking if the command has a first key position
1606+
func (c *ClusterClient) keyedCmds(cmds []Cmder) []Cmder {
16041607
keyedCmds := make([]Cmder, 0, len(cmds))
1605-
keylessCmds := make([]Cmder, 0, len(cmds))
16061608
for _, cmd := range cmds {
1607-
if cmdFirstKeyPos(cmd) == 0 {
1608-
keylessCmds = append(keylessCmds, cmd)
1609-
} else {
1609+
if cmdFirstKeyPos(cmd) != 0 {
16101610
keyedCmds = append(keyedCmds, cmd)
16111611
}
16121612
}
1613-
return keyedCmds, keylessCmds
1613+
return keyedCmds
16141614
}
16151615

16161616
func (c *ClusterClient) processTxPipelineNode(

0 commit comments

Comments
 (0)