Snapshotting 快照:
默认情况下Redis 保留快照到磁盘,在一个binary 文件称为dump.rdb.
你可以配置Redis 有save数据库每N秒。
如果至少有M个修改在数据集,或者你可以手动的调用SAVE或者BGSAVE命令。
例如,这个配置会让Redis 自动dump 数据集到磁盘 每60秒 如果至少1000个keys改变了:
save 60 1000
这个策略被称为快照
它是如何工作的:
当Redis 需要转储数据到磁盘,会发生什么呢?
1.Redis forks, 我们有一个child和一个parent进程
2.child 开始写数据集到一个临时RDB文件
3.当child 是写RDB文件,它替换老的
这个方法允许Redis从复制写语义中受益