Introduction to Redis
Redis is completely open-source, compliant with the BSD license, and is a high-performance key-value database.
Redis has three distinctive features compared to other key-value caching products:
- Redis supports data persistence, allowing data in memory to be saved to disk and reloaded for use upon restart.
- Redis not only supports simple key-value data types but also provides storage for data structures such as lists, sets, zsets, and hashes.
- Redis supports data backup in a master-slave mode.
Advantages of Redis
- Exceptional performance – Redis can read at a speed of 110,000 operations per second and write at a speed of 81,000 operations per second.
- Rich data types – Redis supports operations on binary-safe Strings, Lists, Hashes, Sets, and Ordered Sets data types.
- Atomic operations – All Redis operations are atomic, meaning they either execute successfully or fail without any action. Single operations are atomic, and multiple operations support transactions, ensuring atomicity, wrapped with MULTI and EXEC instructions.
- Rich features – Redis also supports features like publish/subscribe, notifications, key expiration, and more.
How is Redis Different from Other Key-Value Stores?
- Redis has more complex data structures and provides atomic operations on them, which is a different evolutionary path from other databases. Redis data types are based on fundamental data structures and are transparent to programmers, eliminating the need for additional abstraction.
- Redis runs in memory but can be persisted to disk, so when performing high-speed reads and writes on different datasets, memory needs to be balanced, as the data size cannot exceed hardware memory. Another advantage of an in-memory database is that operations on complex data structures are much simpler in memory compared to disk, allowing Redis to perform many internally complex tasks. Additionally, their disk formats are compact and generated in an append-only manner, as they do not require random access.