This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 4c9edb510 chore(command): add a special category to disable commands
(#3251)
4c9edb510 is described below
commit 4c9edb510d99ac2251f0f00bb4f62758f0516869
Author: Twice <[email protected]>
AuthorDate: Sun Nov 9 11:24:05 2025 +0800
chore(command): add a special category to disable commands (#3251)
During the release process, we usually need to disable certain commands.
Our common approach is to comment out large sections of code, but that
feels somewhat inelegant. Instead, we could introduce a special category
to handle this, which might also be useful during debugging.
---
src/commands/commander.cc | 4 ++++
src/commands/commander.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/src/commands/commander.cc b/src/commands/commander.cc
index ec62a1c5e..d820d3fb8 100644
--- a/src/commands/commander.cc
+++ b/src/commands/commander.cc
@@ -27,6 +27,10 @@ namespace redis {
RegisterToCommandTable::RegisterToCommandTable(CommandCategory category,
std::initializer_list<CommandAttributes> list) {
+ if (category == CommandCategory::Disabled) {
+ return;
+ }
+
for (auto attr : list) {
attr.category = category;
CommandTable::redis_command_table.emplace_back(attr);
diff --git a/src/commands/commander.h b/src/commands/commander.h
index 2179387de..3f38db025 100644
--- a/src/commands/commander.h
+++ b/src/commands/commander.h
@@ -116,6 +116,9 @@ enum class CommandCategory : uint8_t {
Txn,
ZSet,
Timeseries,
+ // this is a special category for disabling commands,
+ // basically can be used for version releasing or debugging
+ Disabled,
};
class Commander {