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:
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)