Is Redis a database or a cache?
Why people call it a cache
Redis keeps data in memory, which makes reads and writes very fast. Many apps put frequently used results, session data, or rate limit counters into Redis so they do not have to hit a slower database every time. That use case is why Redis is so common as a cache.
Redis also supports data structures like lists, sets, and sorted sets, plus features such as pub/sub messaging. These make it useful for leaderboards, queues, and real-time features.
- Common uses include caching and session storage
- Supports lists, sets, and sorted sets
- Can handle queues and pub/sub messages
When it acts as a database
Redis can persist data to disk through snapshots or an append-only log. With careful configuration, some teams use it as a primary store for data that fits in memory. For most relational or long-term records, a dedicated database such as PostgreSQL is still the safer main store.
Treat Redis as a fast layer next to your main database unless you have a clear reason to store primary data in it.
Choose a sensible time-to-live for cached values, and plan how the cache refreshes when source data changes. Monitoring memory use matters because in-memory data can grow quickly.
Common mistakes
- Storing critical records in Redis without setting up persistence.
- Letting cached data go stale because there is no expiration plan.
