NoSQLIntermediate

What is Redis good for beyond caching?

“Name uses of Redis that are not caching, with the data structure each relies on.”

What this tests

  • Redis data structures
  • Atomic operations

Answers by level

Read the beginner answer first and notice what is missing.

Rate limiting (INCR + EXPIRE, or a sorted set for a sliding window), leaderboards and ranks (sorted sets, O(log n)), sessions (a hash with TTL), queues (lists, or streams for at-least-once), distributed locks (SET NX EX), pub/sub fan-out, and atomic counters (INCR).

It is single-threaded, so every command is atomic without locks — that is what makes these primitives correct.

Green flags · Red flags

Strong green flag · Explains why atomicity comes from single-threading.
Green flags
  • Names structures per use case
  • Knows single-threaded → atomic
  • Sorted set for leaderboards/rate limits
Red flags
  • "Redis is just a cache"
  • Only knows GET/SET

Follow-up questions

F1
Implement a per-user rate limit of 5/min.

Scenario

You need a real-time leaderboard for millions of players. Why is a sorted set better than a SQL ORDER BY?

Learn this topic