Redis 是否持久化数据? [英] Does Redis persist data?

查看:48
本文介绍了Redis 是否持久化数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Redis 从内存中提供所有数据,但它是否也能在服务器重新启动后持续存在,以便在服务器重新启动时将磁盘中的所有数据读入内存.或者它总是一个空白存储,只在应用程序运行时存储数据而没有持久性?

I understand that Redis serves all data from memory, but does it persist as well across server reboot so that when the server reboots it reads into memory all the data from disk. Or is it always a blank store which is only to store data while apps are running with no persistence?

推荐答案

我建议你在 http://redis.io/topics/persistence .基本上,当您仅使用内存存储来提高性能时,就会失去保证的持久性.想象一个场景,您 INSERT 到内存中,但在它被持久化到磁盘之前就断电了.会有数据丢失.

I suggest you read about this on http://redis.io/topics/persistence . Basically you lose the guaranteed persistence when you increase performance by using only in-memory storing. Imagine a scenario where you INSERT into memory, but before it gets persisted to disk lose power. There will be data loss.

Redis 支持所谓的快照".这意味着它将在某些时间点(例如,每整整一小时)对内存中的内容进行完整复制.当您在两次快照之间断电时,您将丢失上次快照和崩溃之间的数据(不一定是停电..).Redis 在数据安全与性能之间进行权衡,就像大多数 NoSQL-DB 一样.

Redis supports so-called "snapshots". This means that it will do a complete copy of whats in memory at some points in time (e.g. every full hour). When you lose power between two snapshots, you will lose the data from the time between the last snapshot and the crash (doesn't have to be a power outage..). Redis trades data safety versus performance, like most NoSQL-DBs do.

大多数 NoSQL 数据库都遵循在多个节点之间复制的概念,以最大限度地减少这种风险.Redis 更被认为是一种快速缓存,而不是保证数据一致性的数据库.因此,它的用例通常与真实数据库的用例不同:例如,您可以以无与伦比的性能存储会话、性能计数器或其中的任何内容,并且在发生崩溃时没有真正的损失.但是处理订单/购买历史记录等被认为是传统数据库的工作.

Most NoSQL-databases follow a concept of replication among multiple nodes to minimize this risk. Redis is considered more a speedy cache instead of a database that guarantees data consistency. Therefore its use cases typically differ from those of real databases: You can, for example, store sessions, performance counters or whatever in it with unmatched performance and no real loss in case of a crash. But processing orders/purchase histories and so on is considered a job for traditional databases.

这篇关于Redis 是否持久化数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆