Lesson 9 / 18
Hashes
A field-value map inside one key — like a mini object.
HSET & HGET
A hash groups related fields under one key instead of spreading them across many SET calls.
HSET user:1 name "Ada" age "36" city "London"
HGET user:1 name
HGETALL user:1
Output:
(integer) 3 "Ada" 1) "name" 2) "Ada" 3) "age" 4) "36" 5) "city" 6) "London"
Updating one field
HINCRBY bumps a numeric field without touching the rest of the hash.
HINCRBY user:1 login_count 1
Output:
(integer) 1
A record in a drawer
Think of a hash as one drawer (user:1) holding labeled slips of paper (fields) — you can pull out just name without opening the whole drawer.