2 · REDIS · DATA TYPES
← Lesson 1: Redis
▶ Run: P4
Data Types and Access Methods
LINE
HASH
A SET WITH A COUNT
LIST
string
hash
sorted set
list
SET session:9f3a 1042 EX 1800
Session, flag, counter, serialized object. Supports INCR—atomically.
HSET player:1042:profile level 13
Profile cache: HGET / HSET of a single field without overwriting the entire object.
ZADD leaderboard:season:7 1,500 player:1,042
Leaderboard, chronological order, pending tasks. The order is maintained automatically.
RPUSH matchmaking:queue:ranked 1042
FIFO, as in the matchmaker from Lesson 1. Without ACK: a failure after LPOP results in the task being lost.
The current value has one type. A GET request by hash returns "WRONGTYPE"; "TYPE" returns the type but not the field values.
There is no general WHERE clause based on fields—the indexes are maintained by the application itself. The `set region:eu:players` table stores the IDs of players in the region; the application updates it when the region changes or a profile is deleted. For each query, specify in advance the key or index structure and the cost of maintaining it. Launch — P4.
▶P16: HyperLogLog
▶ P11: Streams