Skip to content

feat(command): add FLUSHSLOTS command to clear keys in specified slot ranges in cluster mode#3375

Open
sryanyuan wants to merge 1 commit intoapache:unstablefrom
sryanyuan:feat-flush-slot
Open

feat(command): add FLUSHSLOTS command to clear keys in specified slot ranges in cluster mode#3375
sryanyuan wants to merge 1 commit intoapache:unstablefrom
sryanyuan:feat-flush-slot

Conversation

@sryanyuan
Copy link
Contributor

Add FLUSHSLOTS command to clear keys in specified slot ranges in cluster mode

FLUSHSLOTS allows clearing keys from one or more cluster slots without affecting other slots.
It operates on the current connection's namespace (cluster mode does not support multiple namespaces).

The command returns an error if a slot migration is in progress to prevent conflicts.

Slot ranges can be specified as:
- Single slot: FLUSHSLOTS 1234
- Range: FLUSHSLOTS 100-200
- Multiple ranges: FLUSHSLOTS “0 2 4 6-9”

Example:
FLUSHSLOTS "0 2 4 6-9"

Unit tests have been added to verify clearing multiple slots and ensuring remaining keys match expectations.

Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

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

Should it be a CLUSTERX subcommand, or at least in cmd_cluster.cc instead of cmd_server.cc?

@sryanyuan
Copy link
Contributor Author

Should it be a CLUSTERX subcommand, or at least in cmd_cluster.cc instead of cmd_server.cc?

I agree — this command would be more appropriately placed under the CLUSTERX command as a subcommand, given that it relates to slot operations.

I will update the implementation accordingly.

Thank you for highlighting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants