MCPcopy
hub / github.com/redis/go-redis / cmdSlotWithPos

Method cmdSlotWithPos

osscluster.go:2369–2375  ·  view source on GitHub ↗

cmdSlotWithPos computes the cluster slot for cmd given a pre-resolved first key position. Separating pos resolution from slot computation lets callers that already know pos avoid a redundant Peek() call.

(cmd Cmder, pos int, prefferedSlot int)

Source from the content-addressed store, hash-verified

2367// position. Separating pos resolution from slot computation lets callers that
2368// already know pos avoid a redundant Peek() call.
2369func (c *ClusterClient) cmdSlotWithPos(cmd Cmder, pos int, prefferedSlot int) int {
2370 args := cmd.Args()
2371 if args[0] == "cluster" && (args[1] == "getkeysinslot" || args[1] == "countkeysinslot") {
2372 return args[2].(int)
2373 }
2374 return cmdSlot(cmd, pos, prefferedSlot)
2375}
2376
2377func cmdSlot(cmd Cmder, pos int, prefferedRandomSlot int) int {
2378 if pos == 0 {

Callers 2

slottedKeyedCommandsMethod · 0.95
cmdSlotMethod · 0.95

Calls 2

cmdSlotFunction · 0.85
ArgsMethod · 0.65

Tested by

no test coverage detected