slottedKeyedCommands returns a map of slot to commands taking into account only commands that have keys.
(ctx context.Context, cmds []Cmder)
| 1937 | // slottedKeyedCommands returns a map of slot to commands taking into account |
| 1938 | // only commands that have keys. |
| 1939 | func (c *ClusterClient) slottedKeyedCommands(ctx context.Context, cmds []Cmder) map[int][]Cmder { |
| 1940 | cmdsSlots := map[int][]Cmder{} |
| 1941 | |
| 1942 | // Peek once outside the loop, one RLock for the whole batch instead of |
| 1943 | // two per command (one for the keyless check, one inside cmdSlot). |
| 1944 | cachedInfo := c.cmdsInfoCache.Peek() |
| 1945 | |
| 1946 | prefferedRandomSlot := -1 |
| 1947 | for _, cmd := range cmds { |
| 1948 | var info *CommandInfo |
| 1949 | if cachedInfo != nil { |
| 1950 | info = cachedInfo[cmd.Name()] |
| 1951 | } |
| 1952 | |
| 1953 | pos := cmdFirstKeyPosWithInfo(cmd, info) |
| 1954 | if pos == 0 { |
| 1955 | continue |
| 1956 | } |
| 1957 | |
| 1958 | slot := c.cmdSlotWithPos(cmd, pos, prefferedRandomSlot) |
| 1959 | if prefferedRandomSlot == -1 { |
| 1960 | prefferedRandomSlot = slot |
| 1961 | } |
| 1962 | |
| 1963 | cmdsSlots[slot] = append(cmdsSlots[slot], cmd) |
| 1964 | } |
| 1965 | |
| 1966 | return cmdsSlots |
| 1967 | } |
| 1968 | |
| 1969 | func (c *ClusterClient) processTxPipelineNode( |
| 1970 | ctx context.Context, node *clusterNode, cmds []Cmder, failedCmds *cmdsMap, |
no test coverage detected