我想将redis纯粹用作缓存。我必须在redis.conf中禁用哪些选项以确保这一点。我读到默认情况下redis持久化数据(AOF和rdb文件,或许更多)。对于即将设置为过期的键也是如此。 坚持设置为过期的数据是不是自相矛盾?
答案 0 :(得分:0)
Redis将其所有数据存储在RAM中,但不时将其转储到持久存储(HDD / SDD)。此过程称为快照。
您可以在your redis.conf
file中配置快照频率(请参阅SNAPSHOTTING
部分):
# 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 ""
save 900 1
save 300 10
save 60 10000
因此,如果要完全禁用快照,则应删除或评论save
文件中的所有redis.conf
指令。