Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Config Rewrite Command

Redis Config Rewrite Command

Redis Server

The Redis Config Rewrite command rewrites the redis.conf configuration file specified when starting the Redis server.

CONFIG SET The command can modify the server's current configuration, 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 currently used configuration 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 succeeds, or an error if it fails.

Example

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 处于关闭状态

1) "appendonly"

2) "no"



127.0.0.1:6379> CONFIG SET appendonly yes       # 打开 appendonly

OK



127.0.0.1:6379> CONFIG GET appendonly

1) "appendonly"

2) "yes"



127.0.0.1:6379> CONFIG REWRITE                  # 将 appendonly 的修改写入到 redis.conf 中

OK

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



# ... other options



appendonly yes



# ... other options

Redis Server