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

Comando Redis Config rewrite

Redis 服务器

Il comando Redis Config rewrite modifica il file di configurazione redis.conf specificato durante l'avvio del server Redis.

CONFIG SET Il comando può modificare la configurazione corrente del server, e la configurazione modificata potrebbe non essere la stessa descritta nel file redis.conf. Il ruolo del comando CONFIG REWRITE è registrare la configurazione corrente utilizzata dal server nel file redis.conf con il minor numero di modifiche possibile.

Sintassi

La sintassi di base del comando redis Config rewrite è la seguente:

redis 127.0.0.1:6379> CONFIG REWRITE parameter

可用版本

>= 2.8.0

返回值

一个状态值:如果配置重写成功则返回 OK ,失败则返回一个错误。

在线示例

以下是执行 CONFIG REWRITE 前, 被载入到 Redis 服务器的 redis.conf 文件中关于 appendonly 选项的设置:

# ... 其他选项
appendonly no
# ... 其他选项

在执行以下命令之后:

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

重写后的 redis.conf 文件中的 appendonly 选项将被改写:

# ... 其他选项
appendonly yes
# ... 其他选项

Redis 服务器