CONFIG REWRITE

    The command rewrites the 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.

    • Comments and the overall structure of the original redis.conf are preserved as much as possible.
    • If an option was not already present, but it is set to its default value, it is not added by the rewrite process.
    • Non used lines are blanked. For instance if you used to have multiple 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.

    *Return value

    : when the configuration was rewritten properly. Otherwise an error is returned.