gpt4 book ai didi

redis - 配置redis作为缓存

转载 作者:可可西里 更新时间:2023-11-01 10:59:54 25 4
gpt4 key购买 nike

我想纯粹用redis做缓存。我必须在 redis.conf 中禁用哪些选项才能确保如此。我读到默认情况下 redis 会保留数据(AOF 和 rdb 文件,也许还有更多)。即使是设置为过期的 key 也是如此。持久化设置为过期的数据是不是自相矛盾?

最佳答案

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

因此,如果您想完全禁用快照,您应该删除或注释掉 redis.conf 文件中的所有 save 指令。

关于redis - 配置redis作为缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29428814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com