-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat:add big key detection #3115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.5
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,7 +267,8 @@ class InfoCmd : public Cmd { | |
| kInfoAll, | ||
| kInfoDebug, | ||
| kInfoCommandStats, | ||
| kInfoCache | ||
| kInfoCache, | ||
| kInfoBigKeys | ||
| }; | ||
| InfoCmd(const std::string& name, int arity, uint32_t flag) : Cmd(name, arity, flag) {} | ||
| void Do() override; | ||
|
|
@@ -277,6 +278,7 @@ class InfoCmd : public Cmd { | |
| void Execute() override; | ||
|
|
||
| private: | ||
| int bigkeys_limit_ = 0; | ||
| InfoSection info_section_; | ||
| bool rescan_ = false; // whether to rescan the keyspace | ||
| bool off_ = false; | ||
|
|
@@ -295,15 +297,19 @@ class InfoCmd : public Cmd { | |
| const static std::string kDebugSection; | ||
| const static std::string kCommandStatsSection; | ||
| const static std::string kCacheSection; | ||
| const static std::string kBigKeysSection; | ||
|
|
||
| void DoInitial() override; | ||
| void Clear() override { | ||
| rescan_ = false; | ||
| off_ = false; | ||
| keyspace_scan_dbs_.clear(); | ||
| info_section_ = kInfoErr; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里在 Clear() 情况下为什么要置为 kInfoErr 状态,什么场景下这个命令会调用 Clear()
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我用 kInfoErr 状态代表一个错误或者未初始化的状态。确保命令对象在被重用之前,其内部状态恢复到初始状态,防止数据污染。当一个命令执行完成后,Clear() 方法会被调用,清理内部状态,释放资源,为下次复用做准备。 |
||
| bigkeys_limit_ = 0; | ||
| } | ||
|
|
||
| void InfoServer(std::string& info); | ||
| void InfoBigKeys(std::string& info); | ||
| void InfoClients(std::string& info); | ||
| void InfoStats(std::string& info); | ||
| void InfoExecCount(std::string& info); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里默认改成0吧,默认不打印
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done