Skip to content

Use CommandInfo to determine first key position in cmdFirstKeyPos #3803

@retr0-kernel

Description

@retr0-kernel

There's a TODO in command.go:

// TODO: Use the data in CommandInfo to determine the first key position.

Right now cmdFirstKeyPos hardcodes a handful of special cases and falls back to position 1 for everything else. The problem is we already fetch CommandInfo (which includes FirstKeyPos) via COMMAND INFO and cache it, we're just not using it here.

The keylessCommands map also has to be kept in sync manually, which is easy to get wrong as new commands are added.

The fix would be to look up CommandInfo in cmdFirstKeyPos when available and use FirstKeyPos from there, keeping the current logic as a fallback for cold cache. The eval/evalsha family would still need special handling since their key position depends on the numkeys argument at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions