Skip to content
Devgo

Redis

An in-memory key-value store used as a cache, database, message broker, and session store. Extremely fast (sub-millisecond). Redis stores data in memory with optional persistence. The most popular cache. Supports strings, lists, sets, sorted sets, hashes, streams, and pub/sub.

Created by

Salvatore Sanfilippo (antirez) · Created Redis in 2009

When to use
  • Caching hot data.
  • Session storage.
  • Rate limiting counters.
  • Real-time leaderboards (sorted sets).
  • Pub/sub messaging.
When not to
  • Primary persistent database (memory cost).
  • Complex queries (use SQL).
  • Large datasets that don't fit in memory.

Definition

Redis is an in-memory store. You set/get keys (strings, lists, sets, hashes, sorted sets, streams). Single-threaded, event-looped, sub-millisecond latency. Optional persistence (RDB snapshots, AOF log). for messaging. Lua scripting. Cluster for sharding.

Why it exists

Disk-based databases are too slow for hot data (sessions, caches, leaderboards). Redis keeps data in memory for sub-millisecond access, acting as a fast layer in front of slower databases.

How it works

SET key value, GET key. EXPIRE sets TTL. Data types: strings, lists (LPUSH/RPOP), sets (SADD/SMEMBERS), sorted sets (ZADD/ZRANGE), hashes (HSET/HGET), streams (XADD/XREAD). : PUBLISH/SUBSCRIBE. Persistence: RDB () or AOF (append log).

Scaling limits

Memory is finite and expensive. Single-threaded (one core for commands). Persistence adds overhead. Cluster sharding is complex. No complex queries (key-based access only).

Cost shape

Self-hosted (free, you manage). Managed (Redis Cloud, ElastiCache) charges per memory/hour.

Alternatives

  • Memcached — Simpler, multi-threaded, but strings only, no persistence.
  • DynamoDB (DAX) — Managed, persistent, but slower and vendor lock-in.

Failure modes

  • Data loss on crash without persistence.
  • Memory exhaustion.
  • Hot keys causing uneven load.
  • Cache stampede (thundering herd).

, , , ,