Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis and Data Integrity

I have some questions for REDIS DB:

  • How to ensure data integrity?
  • Are there methods ensure the integrity?
  • Does Redis primary key? or alternatives
  • Foreign key?
  • Referential Integrity?
  • How are the ACID properties to be implemented?

Ever Thanks for a possible feedback

best regards - SB -

like image 451
viv1d Avatar asked Feb 04 '13 07:02

viv1d


People also ask

Can data lost from Redis?

If your computer running Redis stops, your power line fails, or you accidentally kill -9 your instance, the latest data written to Redis will be lost. While this may not be a big deal for some applications, there are use cases for full durability, and in these cases Redis snapshotting alone is not a viable option.

Is Redis a durable Datastore?

Redis is not usually deployed as a "durable" datastore (in the sense of the "D" in ACID.), even with journaling. Most use cases intentionally sacrifice a little durability in return for speed.

Is Redis ACID compliant?

Redis transactions are not fully ACID compliant ( Atomicity, Consistency, Isolation, and Durability). If ACID transactions are expected, Redis is not the perfect fit and should not be used. An RDBMS or another database system should be used in those scenarios.


1 Answers

Redis is a key/value store on steroids, not a relational database.

How to ensure data integrity? Are there methods ensure the integrity?

Redis supports different persistence options from the "non safe but very efficient" up to the "safe but not very efficient". See more information at:

  • http://redis.io/topics/persistence
  • http://oldblog.antirez.com/post/redis-persistence-demystified.html

Redis also supports a master-slave replication mechanism to protect the data in case of complete node failure.

A single Redis instance always provides data consistency (in the sense of the CAP theorem, not in the sense of ACID).

Does Redis primary key? or alternatives

Redis is a key/value store. All items have a key. There is no concept of primary or secondary key.

Foreign key? Referential Integrity?

These are relational concepts. Redis is not a relational database. Foreign key means nothing (there is no table concept with Redis). Referential integrity is not maintained by Redis, and must be enforced by the client application.

How are the ACID properties to be implemented?

They are not supposed to be implemented since Redis is not a transactional database. There is no rollback mechanism with Redis. However, in term of ACID properties:

  • Atomicity and consistency can be guaranteed for a group of commands with a server-side Lua script
  • Isolation is always guaranteed at command level, and can also be guaranteed for a group of command using a MULTI/EXEC block or a Lua script
  • Durability can be guaranteed when AOF is activated (with systematic fsync)
like image 178
Didier Spezia Avatar answered Sep 28 '22 10:09

Didier Spezia