星空网 > 软件开发 > 数据库

Redis 持久化

持久化概念

持久化是将程序数据在持久状态和瞬时状态间转换的机制。通俗的讲,就是瞬时数据(比如内存中的数据,是不能永久保存的)持久化为持久数据(比如持久化至数据库中,能够长久保存)。

 

Redis持久化

官方说明:http://www.redis.io/topics/persistence

 

持久化方式

RDB (Redis Database) 

AOF (Append Only File)

 

RDB 

Snapshotting

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.

For example, this configuration will make Redis automatically dump the dataset to disk every 60 seconds if at least 1000 keys changed:

save 60 1000

默认Redis保存数据集快照到硬盘,二进制文件名为dump.rdb。

保存数据集

设置

    /etc/redis/6379.conf

save 900 1save 300 10save 60 10000

命令

 SAVE - summary: Synchronously save the dataset to disk since: 1.0.0 group: server

 BGSAVE - summary: Asynchronously save the dataset to disk since: 1.0.0 group: server

SAVE 同步保存  执行期间客户端不能接收任何请求,不能在生产环境执行

BGSAVE 异步保存 

 




原标题:Redis 持久化

关键词:Redis

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流