Redis or Remote Dictionary Server, is an in-memory data structure that can be used as cache, database and message broker. The open source software supports data structures like lists, hashes, strings, sets, bitmaps, sorted sets with range queries and hyperloglogs. Since June 2015, the development of Redis is sponsored by Redis Labs. Earlier, it was sponsored by Vmware and Pivotal Software. Redis, which is written in C is the most popular NoSQL database in containers and ranked the number one NoSQL in User Satisfaction.
Unlike other structured storage systems, Redis supports not only strings but abstract data types like sorted set of strings, which are collections of non-repeating elements ordered by a floating-point number and hash tables, where keys and values are strings and hyperLogLogs is used for approximating and set cardinality size estimation.
Main features of Redis are:
Redis replication is a simple to use, master-slave replication. With this configuration, the slave redis servers are found to be the exact replica or copy of master servers.
- Redis uses asynchronous replication.
- Master could have multiple slaves.
- Slaves can accept connections from other slaves. Slaves can be connected to other slaves in a graph-like structure.
- Replication is also used for scalability to have multiple slaves for read-only queries and also for data redundancy.
- Replication is non-blocking on the slave side.
- Point-in-time snapshots of the dataset at specified intervals.
- Logs every write operation received by the server.
- Automatic partitioning of the key space.
- Supports only single key operations.
- Fault tolerance with failure detection and heartbeat.
- Slave of election and promotion to master.
- Incremental versioning to prevent conflicts.
- Subscribes/publishes between the cluster nodes.
- In-memory nature of Redis ensures high performance.
- Operates as a single process and is single-threaded.
- Stored procedures or Lua scripts for better performance.
- Foundation for transactions in Redis is MULTI, EXEC, DISCARD and WATCH.
- All the commands in a transaction are executed sequentially and are serialized.
- This ensures that the commands are executed as a single isolated operation.
- Redis transaction is atomic.
Why use REDIS?
- Redis can be used in the same manner as memcache.
Real time analysis of events
- Real-time tracking filtering system or spam filtering systems.
- Order by user votes and time
- Leader-board type functionality
- Redis has blocking queues commands apart from the normal queues.
- Redis provides, store random data that can be accessed fast by many servers.
- Redis is a good counter, which is achieved with the help of INCRBY and other similar commands. Keeping stats of all kinds is common like when to block an IP address.
Deletion and filtering
- If a cached article is deleted, it can be removed from the cache by LREM.
Show latest items listings in the home page
- Live in-memory cache
Implement expires on items
- Indexing stuff by time and using the unix time as score.
In short, Redis is a fantastic choice if you need a highly scalable data store shared by multiple processes, multiple applications, or multiple servers.