summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-06-25 17:13:20 +0200
committerantirez <antirez@gmail.com>2018-06-25 17:13:20 +0200
commit91a384a5cdcc01912331ad3bd467b2785f3d406b (patch)
tree6d99bc7e068a7e8a5a691256624689bd3607e7c9
parent903582dd7b1a2cecdb2268b641466c6456aaac9e (diff)
downloadredis-91a384a5cdcc01912331ad3bd467b2785f3d406b.tar.gz
Sentinel command renaming: implement SENTINEL SET.
-rw-r--r--src/sentinel.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index c367efee3..f69713973 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -3467,6 +3467,25 @@ void sentinelSetCommand(client *c) {
goto badfmt;
ri->quorum = ll;
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 {
addReplyErrorFormat(c,"Unknown option or number of arguments for "
"SENTINEL SET '%s'", option);