(Personal notes — written to help future-me remember this fast)
Redis is an in-memory data store — it keeps data in RAM instead of on disk, which is why it's so fast. Disk reads/writes are slow compared to RAM, so anything Redis can serve straight from memory skips a ton of latency.
A cache is a temporary storage spot for data that's requested a lot, so future requests can be answered quickly instead of redoing expensive work every single time.
I'm a customer who keeps ordering the same waffle + drink combo. The shop owner notices this and starts keeping that combo pre-made and within arm's reach, instead of making it from scratch every time I order.
That "keep the popular stuff within arm's reach" behavior = caching.
| Database (e.g. MongoDB) | Redis | |
|---|---|---|
| Role | Source of truth | Fast access layer / cached copy |
| Storage | Disk | RAM (memory) |
| Speed | Slower | Much faster |
| Persistence | Permanent | Temporary (can expire, can be lost) |
Important correction to keep in mind: Redis is not just a "GET-only" cache tool. It fully supports both reads and writes — you can SET, increment counters, push to lists, etc. My current learning example happens to be about caching + read-heavy workloads (API caching), but that's just one use case, not the whole picture of what Redis does.
Without Redis: