如何删除磁盘上的Redis key



我是Redis的新手,我试图在Ram上删除一个密钥,但它已经存在于磁盘上的哑文件中。重启服务器后,Ram上的key已经存在。请帮帮我。如何在ram和磁盘之间同步数据?

根据您的配置文件,您可以修改您的redis config file,例如

appendonly yes
appendfsync always
# appendfsync everysec
# append

希望有帮助。

appendonly yes
appendfsync always
# appendfsync everysec
# append
像Javy说的那样做肯定会有帮助,这会使内存中的数据每秒同步到磁盘。另一种方法是发出BGSAVE命令来生成新的转储。RDB文件。我认为您应该修改自动转储执行的频率。这在redis.conf文件中。查看项目保存

我想我最好把相关段落给你贴出来:

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

如果您不知道如何修改配置文件,请按指定的顺序输入以下命令:

config set appendonly yes
config set appendonly everysec
config rewrite

如果有不清楚的地方,请随时回复。

最新更新