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)
| 181 | // so this function never independently re-peeks the cache — avoids the |
| 182 | // cold --> warm inconsistency the reviewer flagged. |
| 183 | func (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 |
| 202 | func createCommandByType(ctx context.Context, cmdType CmdType, args ...interface{}) Cmder { |
no test coverage detected