Skip to content

What is Redis?

Redis stores every key and its associated value directly in RAM. When your application sets a key, the data lives in memory — no disk seek, no page fault, no file-system overhead. When it reads the key back, the answer comes from the same memory. This is why Redis latency is consistently sub-millisecond even under heavy load.

Each value is typed. Redis is not a simple string bag — it understands data structures natively: Strings, Lists, Hashes, Sets, Sorted Sets, Streams, and more. The server can operate on those structures atomically, which means you can append to a list, increment a counter, or pop from a queue without any application-level locking.

Redis processes commands through a single-threaded event loop. One thread reads a command from the network socket, executes it completely, writes the reply, then moves on to the next command. There is no parallelism inside a single Redis instance.

This design has two important consequences:

  • Speed — no context switching, no mutex contention, no lock overhead. The event loop squeezes maximum throughput out of a single core.
  • Thread safety by design — because only one command runs at a time, every command is implicitly atomic. You never need to worry about two clients corrupting shared state mid-operation.

The phrase “Redis is a cache” is common but incomplete. A plain cache maps keys to opaque blobs. Redis maps keys to rich data structures you can manipulate on the server side:

TypeDescription
StringText, numbers, or raw bytes up to 512 MB
ListOrdered sequence; push/pop from either end
HashField-value map inside a single key
SetUnordered collection of unique members
Sorted SetSet where each member carries a numeric score
StreamAppend-only log of timestamped entries

Because operations happen server-side, you avoid round trips. Instead of GET → modify locally → SET, you do LPUSH or ZINCRBY in one network call.

Use caseRedis feature
CacheTTL-based expiry on any key
Session storeHash per session ID, fast reads
Task queueLPUSH / BRPOP on a List
LeaderboardSorted Set with ZADD / ZRANK
Rate limiterINCR + EXPIRE on a counter key
Pub/Sub messagingPUBLISH / SUBSCRIBE channels

Run PING to confirm the server is alive, then use TYPE to inspect any key:

127.0.0.1:6379> PING
PONG
127.0.0.1:6379> SET language "Redis"
OK
127.0.0.1:6379> TYPE language
string
PING
Why is Redis so fast compared to disk-based databases?
How does the single-threaded event loop make Redis thread-safe?
Which Redis data type would you use to implement a leaderboard with ranked scores?
What command would you use to check the data type of an existing Redis key?