Redis Config Rewrite Command
The Redis Config rewrite command rewrites the redis.conf configuration file specified when starting the Redis server.
The CONFIG SET command can modify the current configuration of the server, and the modified configuration may differ from the configuration described in the redis.conf file. The purpose of CONFIG REWRITE is to record the server's current configuration in the redis.conf file with minimal changes.
Syntax
The basic syntax for the redis Config rewrite command is as follows:
redis 127.0.0.1:6379> CONFIG REWRITE parameter
Available Versions
= 2.8.0
Return Value
A status value: returns OK if the configuration rewrite is successful, or an error if it fails.
Example
Below is the appendonly option setting in the redis.conf file loaded into the Redis server before executing CONFIG REWRITE:
# ... other options
appendonly no
# ... other options
After executing the following commands:
127.0.0.1:6379> CONFIG GET appendonly # appendonly is turned off
1) "appendonly"
2) "no"
127.0.0.1:6379> CONFIG SET appendonly yes # Turn on appendonly
OK
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "yes"
127.0.0.1:6379> CONFIG REWRITE # Write the appendonly modification to redis.conf
OK
The appendonly option in the rewritten redis.conf file will be modified:
# ... other options
appendonly yes
# ... other options