An Overview of Redis: Data Types, Features, Persistence, Clustering, and Use Cases
Redis is an open-source, in‑memory key‑value store written in C that supports multiple data structures, offers high‑performance caching, persistence via RDB and AOF, various clustering solutions such as Codis and native Redis Cluster, and is widely used for caching, ranking, session management, queues, and pub/sub.
What is Redis
Redis is a high‑performance, open‑source in‑memory key‑value store written in ANSI C. It provides fast access to data, supports persistence, and offers a rich set of data structures that can be accessed directly from many programming languages.
Redis Data Types
String : Simple key‑value pairs, can store text or numbers.
List : Double‑ended linked list of strings, usable as stack or queue.
Hash : Mapping of fields to values, ideal for representing objects.
Set : Unordered collection of unique strings.
Sorted Set : Set with a score, allowing ordered retrieval based on the score.
Key Features
1. Single‑threaded architecture with an event loop that eliminates lock contention. 2. In‑memory storage with optional persistence for durability. 3. Supports master‑slave replication and read‑write separation for scalability. 4. Rich data‑type operations and atomic transactions. 5. Built‑in expiration and eviction policies.
Persistence Mechanisms
RDB (Redis Database)
Periodically snapshots the dataset to a binary file on disk. The snapshot is created by forking a child process, writing to a temporary file, and then atomically replacing the old file.
AOF (Append‑Only File)
Logs every write operation to a file in an append‑only fashion. The log can be replayed to reconstruct the dataset, providing a more granular persistence option.
Clustering Solutions
Codis Architecture
Codis is an open‑source proxy written in Go that provides sharding based on consistent hashing. It separates shards into independent master‑slave groups and stores routing information in Zookeeper or etcd, allowing dynamic scaling without downtime.
Official Redis Cluster
Redis Cluster is built into Redis, supporting linear scaling to thousands of nodes with a master‑only architecture, no central coordinator, and client‑side slot hashing for direct node communication.
Typical Application Scenarios
Full‑page caching : Store rendered HTML to reduce response latency.
Leaderboards / Counters : Fast increment/decrement operations for ranking and counting.
Shared Session Store : Centralized session management for web applications.
Message Queues : Implement reliable queues for email sending, task processing, etc.
Publish/Subscribe : Real‑time chat, notification systems, and other event‑driven architectures.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Mike Chen's Internet Architecture
Over ten years of BAT architecture experience, shared generously!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
