Redis 内存数据存储

Redis in-memory data Storage

Redis 是内存中的数据库,但同时持久存在于磁盘上。

Q1: 那么请问这是不是表示redis服务器启动的时候会自动把磁盘上的数据全部加载到内存中呢?

Q2: 还有往redis写数据的时候,会同时更新内存和磁盘吗?

谁能帮我回答一下我的两个问题?

Q1: So I wonder does this mean that when redis server starts, it will automatically load all the data on the disk into memory?

是的,根据配置,Redis 执行内存快照到磁盘,当 Redis 重新启动时,它可以拍摄最新的快照并自动将其再次放入内存。

Q2: And when writing data to redis, will it both update in the memory and the disk?

Redis 优先考虑内存写入和磁盘写入在单独的线程中完成。那么答案是是的,它会将数据写入内存和磁盘,但可能会发生服务器故障可能会导致数据丢失,因为 Redis 并不是必须将数据持久化到磁盘。

查看官方文档about persistence以了解有关该主题的更多信息。