在 REDIS 数据库上执行 CRUD 操作时,必须指定在对键/值进行操作时应用的数据库。我想知道是否可以快照(持久化)某个特定数据库的键/值而不是其他数据库?
我喜欢使用一个数据库来管理序列化设置,而使用另一个数据库来存储集合数据,这些数据也可以从 R 中访问,但应该严格存储在内存中且非持久化。
谢谢
最佳答案
TL:DR; 您不能为一个数据库启用快照而不为其他数据库启用。
在这种情况下(处理多个工作流时)最好的办法是使用自己的配置生成 2 个 redis 服务器。
然后您将能够设置一个没有持久性的 Redis 服务器(严格在内存中)(save ""
)和另一个具有细粒度持久性的 取决于您的写入用途。
参见 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 at all commenting all the "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 ""
关于database - Redis DB,是否可以为某些数据库启用快照而不为其他数据库启用快照?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15194727/