Skip to content

Enable saving of command keys #3130

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Conversation

ofekshenawa
Copy link
Collaborator

@ofekshenawa ofekshenawa commented Sep 20, 2024

Adds support for extracting and persisting the Redis keys used by each command—particularly multi‐key commands.

Key changes:

  • New Keys() method on the Cmder interface, allowing callers to retrieve all keys a command operates on.
  • Extended baseCmd to track a keys []string slice and implement Keys() []string.
  • Helper for interleaved args: introduced getInterleavedArgumentsWithOffset(offset int) []string to extract key names from commands with key/value pairs (e.g. MSET, MSETNX).
  • Command implementations in string_commands.go updated to populate cmd.keys for:
    • Single‐key commands (e.g. GET, SET, INCRBY, APPEND)
    • Multi‐key commands (MGET, MSET, MSETNX)

command.go Outdated
keys := []string{}

switch cmd.Name() {
case "mget":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach isn't scalable, each time we need a new type of extracting we have to add a command here. Cmder is an interface that should be abstract as possible and should not contain any implementation specific (mget is an implementation specific in this case).

Cmder should return a keys, but shouldn't be aware about the keys position of specific command (this is implementation details), instead the specific command that implements this interface should define keys position for itself.

@ndyakov
Copy link
Member

ndyakov commented Apr 22, 2025

@vladvildanov , @ofekshenawa should we close this one? Can someone explain what was the need and the plan for this change?

@ofekshenawa
Copy link
Collaborator Author

ofekshenawa commented Apr 23, 2025

@vladvildanov , @ofekshenawa should we close this one? Can someone explain what was the need and the plan for this change?

This PR enables saving the keys used by commands—especially multi-key commands—for use in CSC.

@ofekshenawa ofekshenawa changed the title Return keys from commands Enable saving of command keys Apr 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants