A fast in-memory data store commonly used for cache, sessions, rate limits, counters, and temporary state.
01 · What is it?
Redis is a shared data store that keeps commonly needed values in memory so applications can read or update them quickly.
It is often used for data that is fast-changing, short-lived, or expensive to calculate again. Redis can support persistence and replication, but teams usually choose it for speed and simple access patterns—not as an automatic replacement for a durable system of record.
02 · Think of it like...
A labeled tray at a busy service counter
The back room holds the official records, but the staff keep today's most-used tickets in a tray within arm's reach. They can respond immediately, update a small number, or discard an expired ticket.
Redis plays that fast shared-tray role for software. The tray is useful because it is close and quick; it should not silently become the only place an important business record exists.
03 · What does it do?
An application reads from Redis before doing slower work, or writes a small piece of temporary state that several application instances need to share.
CacheReturn popular data faster
Keep a product page or API result briefly so the system does not query the main database every time.
SessionKeep interaction state
Share login, cart, or multi-step workflow state across multiple application servers.
Rate limitControl request volume
Track how many requests a client has made in a time window and reject excess traffic.
CounterUpdate a number quickly
Maintain views, attempts, inventory signals, or other short-lived counts with atomic increments.
Application request
→
Redis lookup or update
→
Fast result
→
Continue the user action
04 · Where is it used?
Redis is valuable when the product needs a shared, low-latency answer and the state has a clear lifetime or recovery plan.
High-traffic readsProduct and content cache
Serve frequently requested data quickly while it is still fresh enough for the product.
Identity flowLogin and session state
Let several application servers recognize the same short-lived user interaction.
Abuse controlRate limits
Protect an API or login endpoint with a per-user, per-IP, or per-key request budget.
Temporary stateCodes and holds
Store a verification code, idempotency key, or checkout hold with an expiration time.
Product signalsCounters
Increment views, attempts, or live activity without making the main database handle every tiny update.
Operating questionWhat happens if it is empty?
Design a fallback, rebuild path, or user-safe failure before treating Redis as critical state.
05 · Example
A flash-sale product page can use Redis in several focused ways, while the durable order remains in the main database.
1. A shopper opens the product page. The application checks Redis for a short-lived product-page cache.
2. When the shopper clicks Buy, the service uses a Redis counter or short-lived reservation key to coordinate the busy moment.
3. The service writes the confirmed order to the primary database. Redis can make the path faster, but it is not the final proof of purchase.
4. An expiration removes abandoned reservation state. A cache miss or Redis outage follows the product's fallback behavior.
Business record = durable database. Fast temporary state = Redis when the speed, lifetime, and recovery behavior are explicit.
06 · How it connects
Client request
→
Application service
→
Redis read or update
→
Database fallback or durable commit
The exact architecture depends on the role. A cache miss may read from the database and refill Redis; a rate limit may finish inside Redis; an order still needs a durable commit path.
07 · Do Not Confuse
Redis ≠ Cache
Redis is a technology. A cache is a pattern: keep a reusable copy closer to the caller. Redis can provide a cache, but it can also hold sessions, counters, and other state.
Redis ≠ Primary Database
Redis can persist data, but many product designs treat its contents as rebuildable or temporary. Durable business records need an intentional source of truth.
Redis ≠ Message Queue
A queue coordinates work waiting to be processed. Redis usually answers a read or update quickly; a Redis-based queue is a particular design, not what Redis means by default.
Redis ≠ Session
A session is temporary user state. Redis is one place that can store that state, alongside cookies, databases, or other session stores.
Fast ≠ Free
In-memory access is fast, but memory costs money. Expiration, eviction, capacity, replication, and recovery still need operating decisions.
Counter ≠ Final Ledger
A fast counter can support a live signal or guardrail. It should not replace the durable transaction record when correctness and auditability matter.
08 · Topic Glossary
ENGLISH TERM
中文
SIMPLE ENGLISH
中文小白理解
Redis
Redis
A fast in-memory data store.
一种把数据放在内存中、读写很快的数据存储。
In-memory
内存中的
Stored in working memory for quick access.
数据放在运行内存里,所以访问速度快。
Cache
缓存
A reusable copy kept for faster reads.
为了更快读取而暂时保存的一份副本。
Session
会话
Temporary state linked to a user or browser.
和用户或浏览器关联的临时状态。
Rate Limit
速率限制
A rule limiting requests in a time window.
限制一段时间内请求次数的规则。
Counter
计数器
A value that tracks a number and can be incremented.
记录数字并可以快速加一的值。
Expiration
过期时间
The time after which a value is removed or ignored.
到了规定时间后,数据被删除或不再使用。
Eviction
淘汰
Removing stored values when memory or a policy requires it.
内存不够或规则要求时,移除部分数据。
Source of Truth
事实来源
The system trusted for the final durable record.
最终以它保存的正式记录为准的系统。
Cache Miss
缓存未命中
When the requested value is not in the cache.
想要的数据不在缓存里,需要去别处查找。
09 · What to Remember
Redis is a fast shared data store for state that benefits from low latency and has an explicit lifetime, fallback, or recovery plan.
It commonly supports caches, sessions, rate limits, counters, and temporary state. Choosing Redis means also choosing memory capacity, expiration, eviction, persistence, availability, and what happens when the data is missing.
Core idea: Keep fast, shared, temporary state close to the application; keep durable business truth in the system designed to own it.