English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Config rewrite command

Redis Server

The Redis Config rewrite command modifies the redis.conf configuration file specified when starting the Redis server.

CONFIG SET The command can modify the current configuration of the server, and the modified configuration may be different from the configuration described in the redis.conf file. The function of CONFIG REWRITE is to record the current configuration used by the server into the redis.conf file with as few modifications as possible.

Syntax

The basic syntax of the redis Config rewrite command is as follows:

redis 127.0.0.1:6379> CONFIG REWRITE parameter

Available Version

>= 2.8.0

Return Value

A status value: returns OK if the configuration rewrite is successful, and returns an error if it fails.

Online Examples

The following is the setting of the appendonly option in the redis.conf file loaded into the Redis server before executing CONFIG REWRITE:

# ... Other Options
appendonly no
# ... Other Options

After executing the following command:

127.0.0.1:6379> CONFIG GET appendonly           # appendonly is disabled
1) "appendonly"
2) "no"
127.0.0.1:6379> CONFIG SET appendonly yes       # Enable appendonly
OK
127.0.0.1:6379> CONFIG GET appendonly
1) "appendonly"
2) "yes"
127.0.0.1:6379> CONFIG REWRITE                  # Write the modification of appendonly to redis.conf
OK

The appendonly option in the rewritten redis.conf file will be rewritten:

# ... Other Options
appendonly yes
# ... Other Options

Redis Server