通过学习知道redis持久化有AOF和RDB两种方式,但让一个不懂英语的人去记忆AOF和RDB估计要被记成UFO和RMB。真的没有说英文的优越性或者显示自己英文有多好,但真的我是看了几篇文章之后,发现人家的表达精准到位。如下:
AOF stands for Append Only File. It's the change-log style persistent format.
RDB is for Redis Database File. It's the snapshot style persistence format.
所谓change-log,就是改变日志,我们对于日志的理解是记录操作的,那每一个操作都会详尽的记录,有人说AOF保存的是所有执行的命令。这样做的好处自然是数据不会丢失,但弊端也显然在于效率会低一些。
所谓snapshot,即为快照,快照自然是一个阶段一个阶段的去保持记录。所以缺点在于数据会部分丢失,而优点在于效率高。另一种说法是RDB保存的是数据,其实从其全称database file 也可以理解这种方式。
推荐是的AOF。
充分说明了学计算机技术,英文好是多么的重要,记得之前大学时候的教材,好多都是外国的著作翻译过来的,所以有些翻译段落可想而知,我们老师都说它驴唇不对马嘴。
默认情况下,是快照RDB的持久化方式,将内存中的数据以快照的方式写入二进制文件中,默认的文件名是dump.rdb
By default Redis saves snapshots of the dataset on disk, in a binary file called dump.rdb. You can configure Redis to have it save the dataset every N seconds if there are at least M changes in the dataset, or you can manually call the SAVE or BGSAVE commands.
in default config file :
################################ 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 ""
save 900 1
save 300 10
save 60 10000
网友评论