Databases 9 min read

Understanding Redis: Purpose, Usage, Caching Benefits, Differences with Memcached, and Thread Model

This article explains what Redis is, how it is used for caching in projects, the advantages of caching, common cache issues, key differences between Redis and Memcached, and why Redis's single‑threaded design can still support high concurrency.

Big Data Technology & Architecture
Big Data Technology & Architecture
Big Data Technology & Architecture
Understanding Redis: Purpose, Usage, Caching Benefits, Differences with Memcached, and Thread Model

Redis is an open‑source, in‑memory data‑structure store that can serve as a database, cache, and message broker, supporting strings, hashes, lists, sets, sorted sets, bitmaps, hyperloglogs, geospatial indexes, streams, replication, Lua scripting, persistence, high availability via Sentinel, and clustering.

In applications, Redis is primarily used as a cache to store frequently accessed data, reducing the load on underlying databases, improving concurrency, and delivering faster response times.

Caching provides two main benefits: high performance—by avoiding repeated expensive SQL queries—and high concurrency—by handling traffic spikes (e.g., flash sales) without overwhelming the database.

Common cache problems include write‑through inconsistency between cache and database, cache avalanche, cache penetration, and cache concurrency competition.

Compared with Memcached, Redis supports server‑side operations and richer data structures, offers higher memory utilization with hash‑based storage, performs better for small data, provides native clustering, while Memcached may have higher throughput for large simple key‑value data and lacks built‑in clustering.

Redis operates on a single‑threaded reactor model: a file‑event handler uses non‑blocking I/O multiplexing to listen to multiple sockets, dispatching events (AE_READABLE, AE_WRITABLE) to appropriate handlers (connection, request, reply). The client‑server interaction involves associating events with handlers for connection establishment, request processing, and response writing.

Despite being single‑threaded, Redis handles high concurrency because all operations are in‑memory, it relies on non‑blocking I/O multiplexing, and it avoids the overhead of multi‑thread context switches.

Redis memory model diagram
Redis memory model diagram
Redis communication process diagram
Redis communication process diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redisThread ModelIn-Memory DatabaseMemcached Comparison
Big Data Technology & Architecture
Written by

Big Data Technology & Architecture

Wang Zhiwu, a big data expert, dedicated to sharing big data technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.