Redis Server: CONFIG REWRITE
Redis CONFIG REWRITE Command
Redis CONFIG REWRITE command rewrites the redis.conf file which was used to starting the server. Minimal changes needed to make it reflecting the configuration currently used by the server, that 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
- 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.
Here are some common uses and scenarios for the "CONFIG REWRITE" command:
- Persistent Configuration: Rewrites the redis.conf file with the current configuration settings, ensuring that changes are saved for future restarts.
- Configuration Cleanup: Cleans up and removes obsolete or default settings from the configuration file.
- Dynamic Changes: Applies dynamic configuration changes made during runtime to the configuration file for persistence.
- System Maintenance: Facilitates maintenance by updating the configuration file to reflect the current active settings.
- Configuration Management: Helps in managing and organizing Redis configurations systematically, especially after making temporary changes.
Syntax:
CONFIG REWRITE parameter
Available since
2.8.0.
Return Value
String reply, OK when the configuration was rewritten properly. Otherwise, an error is returned.
Return Value Type
String
Previous:
CONFIG GET
Next:
CONFIG SET
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-server-config-rewrite.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics