Redis
Also known as: Redis cache, Redis server, Valkey, ElastiCache
Redis (Remote Dictionary Server) is an in-memory database.
Data lives in RAM, so reads and writes happen in microseconds: far faster than a disk-based database. It's used for caching (storing frequently accessed data), session management, rate limiting, pub/sub messaging, and as a fast key-value store.
Redis, explained at three levels
At home
Redis is like a super-fast notepad that your application keeps in memory. Looking something up takes microseconds instead of milliseconds. When your app needs to show the same data repeatedly (like a leaderboard or session info), Redis serves it almost instantly instead of hitting the database each time.
At work
Developers use Redis to make applications faster by caching: instead of asking the database for the same information 1000 times per second, the result is cached in Redis and served instantly from memory. The database is only queried when the cache expires or changes.
At home
Redis data structures: Strings (simple key-value), Lists, Sets, Sorted Sets (with scores, great for leaderboards), Hashes (like a small object), HyperLogLog (probabilistic cardinality counting), and Streams (append-only log for event streaming). TTL (time-to-live) automatically expires keys after a set time, making cache invalidation simple.
At work
Common Redis patterns: Application caching (cache database query results), Session storage (store user sessions server-side), Rate limiting (track request counts per IP with atomic increment and expire), Pub/Sub (broadcast messages to subscribers), and Distributed locks (coordinate across multiple application instances). Redis Cluster shards data across multiple nodes for horizontal scaling.
At home
Redis executes commands one at a time on a single main thread, so each command is atomic and never interleaved, though network I/O can use extra threads since version 6. Lua scripts and MULTI transactions group several commands atomically. Durability comes from RDB snapshots, an AOF (append-only file) log of writes, or both. In my view, the single thread is Redis's genius and its ceiling: simple consistency, but one slow command blocks everyone.
At work
Redis Sentinel watches a primary and its replicas and promotes a replica automatically if the primary fails. Redis Cluster splits keys across 16,384 hash slots spread over several primaries, adding sharding on top of failover. Since Redis 8, search, JSON, and time series features that once came as separate Redis Stack modules ship in the main distribution, and RedisGraph has been discontinued. Replication is asynchronous, so a failover can lose the last few writes.
Real-world examples
At home
Thomas added Redis caching to his web app for the top 10 most-visited pages. Database queries for those pages dropped by 95%, and response times fell from 200ms to 5ms.
At work
Marcus's team uses Redis for three purposes: caching API responses (TTL 60 seconds), storing user sessions (TTL 24 hours), and implementing rate limiting (100 requests per minute per user using INCR with expire). One Redis cluster handles all three.
Common confusions
- Redis is just a cache and can't be the primary database — Many applications use Redis as a primary database for appropriate use cases: leaderboards, session storage, real-time analytics. With persistence enabled, data survives restarts. Redis is not appropriate for complex relational data, but it's not limited to caching.
- Redis loses all data when the server restarts — By default, Redis can be configured with persistence (RDB snapshots or AOF logging). Most managed Redis services (ElastiCache, Redis Cloud) have persistence enabled by default.
For analysts
Redis is rarely used by BAs directly, but understanding it helps explain why some dashboards update in real time: Redis often powers the leaderboards, counters, and live metrics that feed BI tools.
History & origin
Redis was created by Salvatore Sanfilippo in 2009 while he was working on a startup and needed a fast data structure server for real-time analytics. It quickly became one of the most popular open-source databases. Redis Labs (now Redis Inc.) was formed to commercialize it. In 2024, Redis moved from the BSD licence to source-available licences (RSALv2 and SSPL), prompting forks including Valkey, backed by the Linux Foundation and adopted by AWS and Google Cloud. In 2025, Redis 8 added the open-source AGPL licence as an option.