Redis
Last updated
Was this helpful?
Last updated
Was this helpful?
It is store the data temporarily and obtain the data quickly from the server-side, as the data is stored in ram instead of hard disk in key-value pair
Traditionally, obtain the data from database is slower, as it is required to scan the table, there will be a delay, apart from that, multiple requests to obtain the data from database is not an ideal case
Sometimes, we want the real-time data or do caching , we can make good use of redis to do it
A string in Redis can be up to 512MB in size. Its operation is atomic to prevent from inconsistency when facing multiple access
Redis Hashes are perfect for representing objects. They are a collection of key-value pairs.
Redis Hashes are ideal for storing structured data, like an object with many fields.
Redis Sets are an unordered collection of strings. They support a variety of commands that perform operations based on set theory
Each member of a Sorted Set is associated with a score. This score is used to sort the set members from the smallest to the largest score and and search the result based on the score. The members in a Sorted Set are unique, but the scores may be repeated.
Sorted Sets are particularly useful for tasks that require maintaining a list sorted by a score. For example, they can be used to maintain a leaderboard in online games
Include 1 master and multiple slaves
Write and read can be conducted at master
Slave is for read - only
After the update of master, master will send snapshot to slave for data sync
Master-slave mode requires manual intervention for failover. If the master node fails, a slave node must be promoted manually to become the new master, which can introduce some downtime and administrative overhead.
Sharding. Each node is responsible for their slot (part of data)
Enabling horizontal scaling
Redis Cluster mode provides built-in support for high availability and fault tolerance. It uses a distributed consensus algorithm and automatic failover to ensure data availability even in the event of node failures. If one node is down, others will take its slot to prevent from downtime
s are simply lists of strings, sorted by . They are implemented under the hood using linked lists. This makes it easy to add elements to the beginning or end of the list in constant time.
The key features of Redis lists are their ability to perform push and pop , access elements by index, and more.
Sets, or ZSets, are similar to Redis Sets with an unique feature