InterviewHubPRO
Section Overview
Q42

Question 42 of 60

Part 4: In-Memory Caching & Fast Data Stores (Redis) (41 - 50)

70%
Databases & System Design•Part 4: In-Memory Caching & Fast Data Stores (Redis) (41 - 50)

Core Redis Data Structures:

In Simple Words:

  • Strings: Caching API responses, counters (INCR).
  • Hashes: Storing user objects (HSET).
  • Lists: Queues (LPUSH, RPOP).
  • Sets: Unique tags, mutual friends (SADD, SINTER).
  • Sorted Sets (ZSET): Leaderboards, sliding window rate limiters (ZADD).
bash
# Examples in redis-cli:
SET user:token:123 "session_payload" EX 3600
HSET user:profile:101 name "Alice" role "Admin"
LPUSH task_queue "job_id_55"
SADD active_users "user_1" "user_2"
ZADD leaderboard 1500 "PlayerA" 2300 "PlayerB"