Sentinel command renaming: implement SENTINEL SET.

This commit is contained in:
antirez 2018-06-25 17:13:20 +02:00
parent 903582dd7b
commit 91a384a5cd

View File

@ -3467,6 +3467,25 @@ void sentinelSetCommand(client *c) {
goto badfmt; goto badfmt;
ri->quorum = ll; ri->quorum = ll;
changes++; changes++;
} else if (!strcasecmp(option,"rename-command") && moreargs > 1) {
/* rename-command <oldname> <newname>
*
* Note: if newname is the empty string the command renaming
* entry is deleted. */
sds oldname = c->argv[++j]->ptr;
sds newname = c->argv[++j]->ptr;
/* Remove any older renaming for this command. */
dictDelete(ri->renamed_commands,oldname);
/* If the target name length is not zero, we need to add the
* actual entry to the renamed table. */
if (sdslen(newname)) {
oldname = sdsdup(oldname);
newname = sdsdup(newname);
dictAdd(ri->renamed_commands,oldname,newname);
}
changes++;
} else { } else {
addReplyErrorFormat(c,"Unknown option or number of arguments for " addReplyErrorFormat(c,"Unknown option or number of arguments for "
"SENTINEL SET '%s'", option); "SENTINEL SET '%s'", option);