summaryrefslogtreecommitdiffstats
path: root/iredis/data/commands/config-rewrite.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-21 10:28:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:16:53 +0000
commit06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch)
treee82f1bc439997ae296f2e74f8a64d84c5d95f140 /iredis/data/commands/config-rewrite.md
parentInitial commit. (diff)
downloadiredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz
iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'iredis/data/commands/config-rewrite.md')
-rw-r--r--iredis/data/commands/config-rewrite.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/iredis/data/commands/config-rewrite.md b/iredis/data/commands/config-rewrite.md
new file mode 100644
index 0000000..54509e5
--- /dev/null
+++ b/iredis/data/commands/config-rewrite.md
@@ -0,0 +1,37 @@
+The `CONFIG REWRITE` command rewrites the `redis.conf` file the server was
+started with, applying the minimal changes needed to make it reflect the
+configuration currently used by the server, which may be different compared to
+the original one because of the use of the `CONFIG SET` command.
+
+The rewrite is performed in a very conservative way:
+
+- Comments and the overall structure of the original redis.conf are preserved as
+ much as possible.
+- If an option already exists in the old redis.conf file, it will be rewritten
+ at the same position (line number).
+- If an option was not already present, but it is set to its default value, it
+ is not added by the rewrite process.
+- If an option was not already present, but it is set to a non-default value, it
+ is appended at the end of the file.
+- Non used lines are blanked. For instance if you used to have multiple `save`
+ directives, but the current configuration has fewer or none as you disabled
+ RDB persistence, all the lines will be blanked.
+
+CONFIG REWRITE is also able to rewrite the configuration file from scratch if
+the original one no longer exists for some reason. However if the server was
+started without a configuration file at all, the CONFIG REWRITE will just return
+an error.
+
+## Atomic rewrite process
+
+In order to make sure the redis.conf file is always consistent, that is, on
+errors or crashes you always end with the old file, or the new one, the rewrite
+is performed with a single `write(2)` call that has enough content to be at
+least as big as the old file. Sometimes additional padding in the form of
+comments is added in order to make sure the resulting file is big enough, and
+later the file gets truncated to remove the padding at the end.
+
+@return
+
+@simple-string-reply: `OK` when the configuration was rewritten properly.
+Otherwise an error is returned.