Why this matters
- VaultCommerce bestseller rankings and flash-sale leaderboards need ordered retrieval by score — sorted sets do this in O(log N).
- User profiles and cart summaries change one field at a time; hashes let you update
quantitywithout rewriting the whole cart JSON string. - Interview questions often pair "leaderboard" with sorted sets and "object cache" with hashes — know the command set cold.
StringSessions, counters
ListQueues, feeds
SetUnique tags
Sorted SetLeaderboards
HashUser profiles
StreamEvent log
Hashes: field-level objects
A hash stores field-value pairs under a single key. VaultCommerce keeps lightweight cart state per user:
HSET cart:42 SKU-8842 quantity 2 price 89
HSET cart:42 SKU-1100 quantity 1 price 45
HGET cart:42 SKU-8842
HINCRBY cart:42 SKU-8842 quantity 1
HGETALL cart:42
HDEL cart:42 SKU-1100
EXISTS cart:42
When hashes beat JSON strings
- Partial updates — change one SKU quantity without parsing and rewriting JSON.
- Memory efficiency — Redis encodes small hashes compactly (ziplist/listpack thresholds).
- Field existence —
HEXISTSchecks a single attribute without loading the full object.
For large nested objects (full product catalog entries), a cached JSON string is still fine. Hashes shine when you mutate individual fields frequently.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 3 sections
- Sorted sets: ranked bestsellers
- Range queries and time windows
- Python: cart hash + leaderboard
Test yourself
Answer these before moving on — recall is what makes it stick.