-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: add Rename Command #2453
feat: add Rename Command #2453
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 |
---|---|---|
|
@@ -50,7 +50,7 @@ class BaseConf { | |
bool GetConfIntHuman(const std::string& name, int* value) const; | ||
bool GetConfInt64(const std::string& name, int64_t* value) const; | ||
bool GetConfInt64Human(const std::string& name, int64_t* value) const; | ||
|
||
bool GetConfStr(const std::string& name, std::vector<std::string>* values) const; | ||
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. 这里直接使用 GetConfStrMulti 方法,直接获取一个数组 |
||
bool GetConfStr(const std::string& name, std::string* value) const; | ||
bool GetConfBool(const std::string& name, bool* value) const; | ||
bool GetConfStrVec(const std::string& name, std::vector<std::string>* value) const; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,6 +178,19 @@ bool BaseConf::GetConfStr(const std::string& name, std::string* val) const { | |
return false; | ||
} | ||
|
||
bool BaseConf::GetConfStr(const std::string& name, std::vector<std::string>* values) const { | ||
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. 这个方法用 GetConfStrMulti 替换 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. |
||
for (const auto& i : rep_->item) { | ||
if (i.type == 1) { | ||
continue; | ||
} | ||
if (name == i.name) { | ||
values->push_back(i.value); | ||
} | ||
} | ||
|
||
return !values->empty(); | ||
} | ||
|
||
bool BaseConf::GetConfStrVec(const std::string& name, std::vector<std::string>* value) const { | ||
for (auto& i : rep_->item) { | ||
if (i.type == Rep::kComment) { | ||
|
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.
将 before 转为小写字母,再处理
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.
考虑 after 为 "" 的情况,比如在 conf 文件里面配置的 hget:
rename-command : hget
rename-command : set 360set
redis 里面会先把命令删除了:https://github.com/redis/redis/blob/unstable/src/config.c
另外,如果 before cmd 不存在,直接返回错误,让用户去修改配置文件