Redis DB,是否可以为某些数据库启用快照而不为其他数据库启用快照?

时间:2013-03-04 04:47:12

标签: database serialization redis persistence

在REDIS DB上执行CRUD操作时,必须指定操作键/值时应用的数据库。我想知道是否可能快照(持久化)某个指定数据库的键/值但不能用于其他数据库?

我喜欢使用一个数据库来管理序列化设置,但另一个数据库用于存储集合数据,这些数据也将从R内部访问,但应该严格地在内存中并且是非持久的。

由于

2 个答案:

答案 0 :(得分:2)

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 ""

答案 1 :(得分:1)

不,当redis持久存储到磁盘时,它会将整个数据集保留在磁盘上。此外,不推荐使用multi-db配置,因此我建议不要依赖它。