Part 1 · 1 chapters · ~8 min
Data Structures and Encodings
Strings, hashes, lists, sets, sorted sets, streams, bitmaps, HyperLogLog and geospatial indexes, their commands and complexities, compact listpack and intset encodings and the thresholds that convert them, the SDS string, skiplists, memory per key, and choosing a structure for a use case.
3
Structures and how they are stored
code
SET rate:NGN-USD "1500.00" EX 30 HSET acct:7 currency NGN limit_kobo 20000000 INCR login_fail:[email protected] EXPIRE login_fail:[email protected] 900 LPUSH queue:receipts '{"transfer":"t_1"}' BRPOP queue:receipts 5 ZADD leaderboard 4200 agent:12 ZREVRANGE leaderboard 0 9 WITHSCORES PFADD dau:2026-10-06 u_7 u_9 PFCOUNT dau:2026-10-06 # approximate unique count in 12 KB SETBIT kyc_done:2026-10 7 1 BITCOUNT kyc_done:2026-10 # one bit per user id OBJECT ENCODING acct:7 # "listpack" MEMORY USAGE acct:7 # bytes for this key
DATA STRUCTURES AND THEIR ENCODINGS
small values use compact encodings; large ones switch to faster structures
swipe the figure sideways, or tap expand for full screen
1/6
strings
Strings hold bytes up to 512 MB; integer-valued strings are stored as integers, so INCR, INCRBY and DECR are fast atomic counters.
bytes or integers; atomic countersINCR for counters and limits