Q34 Redis Domain 2 · 25–30% of exam

A team needs rate limiting per API client in Redis. Which approach correctly counts requests within a sliding window?

  1. A INCR with fixed TTL (fixed window)
  2. B Sorted Set with ZADD timestamp, ZREMRANGEBYSCORE, ZCARD (sliding window) (correct answer)
  3. C List with LPUSH/LLEN
  4. D Hash with HINCR

Shortcut: The sliding window rate limiter stores request timestamps in a Sorted Set, removes entries older than the window (ZREMRANGEBYSCORE), and counts remaining entries (ZCARD) to determine if the limit is exceeded.