Introduction Redis is a data-structure server store. Store data in the form of key/value pair. Consistency is guaranteed by supporting "append-only file" and the availability of data is guaranteed through cluster and master-slave replication. And it also has very cool value types: Lists Sets and Sorted sets Hash tables
Redis Datatypes (String) Starting Redis is ve ry easy, you just need to install the desired redis package and write $ redis-server to run the in memory redis server. Key-value simple example: $ SET fb www.facebook.com $ GET fb $ www.facebook.com
Compl ex Datatypes (Hash) Hashes are like nested Redis Objects that can take any number of key-value pairs. $ HMSET user:eric name "Eric Redmond" password s3cret Single redis key can be used to retrieve all values of the hash.
Compl ex Datatypes (List) Lists contain multiple ordered values that can act as both queues (FIFO) and stacks (FILO). Can exceute actions such as adding element in the middle, deleting values, ...
Compl ex Datatypes (Set) Sets are unordered collections that does not allow for duplication. Accepts set operations such as UNION and INTERSECTION
Data Expiry One of the best uses of Redis key-value store is fast-access cache for data that's more expensive to retrieve or compute. As we know cache should be expired and get updated periodically. Using Redis you can mark a key for expiration by using EXPIRE command and give the key time to live in seconds
Durability With Redis you can choose between no persistent or save your data. No persistent will keep the values in the main-memory. No persistent is best choice if you run a caching server because durability will increase the latency. You can also force storing data to disk by using SAVE command (or BGSAVE for asynchronous save)
Durability (Cont.) Redis also provides append-only file that keeps a record of all write commands. That ensures correct value even if the server craches before value saved. The Redis server executes the commands on the startup. By append-only file we can be sure that the data is eventually consistent.
Master-Slave Replication Redis supports master-slave replication (one server is master by defualt) The replication feature allows Redis to ensure the availability. Even if the main server is down, slave servers already have the replicated data and ready to serve clients.
Redis Cluster Clustering is the advanced mode of replication In this mode the servers are master servers and are connected to each other. Clustering makes Redis suitable for distributed systems. The clus tering gives you the ability to automatically split your dataset among multiple nodes . The op eration will continue even if some nodes are failed without having to expire most keys.
B loom Filter s A Bloom filter is a data structure designed to tell you, rapidly and memory-efficie n tly, whe t her an el ement is pres ent in a set. Despite of being very fast, but bloom filters have probabilistic datastructure. with bloom filters we can know that the element either definitely is not in the set or may be in the set. Bloom filters are excellent choice to reduce the unnecessary traffic to a slower underlying system.