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

Method createSlotSpecificCommand

osscluster_router.go:183–199  ·  osscluster_router.go::ClusterClient.createSlotSpecificCommand

createSlotSpecificCommand creates a new command for a specific slot's keys. firstKeyPos is passed in from the caller (computed once in executeMultiShard) so this function never independently re-peeks the cache — avoids the cold --> warm inconsistency the reviewer flagged.

(ctx context.Context, originalCmd Cmder, keys []string, firstKeyPos int)

Source from the content-addressed store, hash-verified

181// so this function never independently re-peeks the cache — avoids the
182// cold --> warm inconsistency the reviewer flagged.
183func (c *ClusterClient) createSlotSpecificCommand(ctx context.Context, originalCmd Cmder, keys []string, firstKeyPos int) Cmder {
184 originalArgs := originalCmd.Args()
185
186 // Build new args with only the specified keys
187 newArgs := make([]interface{}, 0, firstKeyPos+len(keys))
188
189 // Copy command name and arguments before the keys
190 newArgs = append(newArgs, originalArgs[:firstKeyPos]...)
191
192 // Add the slot-specific keys
193 for _, key := range keys {
194 newArgs = append(newArgs, key)
195 }
196
197 // Create a new command of the same type using the helper function
198 return createCommandByType(ctx, originalCmd.GetCmdType(), newArgs...)
199}
200
201// createCommandByType creates a new command of the specified type with the given arguments
202func createCommandByType(ctx context.Context, cmdType CmdType, args ...interface{}) Cmder {

Callers 1

executeMultiSlotMethod · 0.95

Calls 3

createCommandByTypeFunction · 0.85
ArgsMethod · 0.65
GetCmdTypeMethod · 0.65

Tested by

no test coverage detected