Build the mental model
A Redis hash stores field/value pairs under one key. `HGET`, `HSET`, and `HINCRBY` update individual fields without parsing and replacing an entire JSON string. Nested objects, schema validation, or whole-object compression may favor another representation. TTL traditionally applies to the key, while field-expiry support depends on version, command availability, and design.
Connect it to a real scenario
Store a session profile as a hash and update plan, locale, and last_seen independently. Numeric fields can change atomically with `HINCRBY`. Very large hashes become single-key hotspots and can complicate migration and deletion latency.
Try the working example
HSET session:abc123 user_id 42 locale mm plan free last_seen 2026-08-28T10:00:00Z
HGET session:abc123 user_id
HMGET session:abc123 locale plan
HINCRBY session:abc123 requests 1
HGETALL session:abc123
EXPIRE session:abc123 1800You have a session hash with field-level updates and a 30-minute TTL.5-minute try-it
Create a tutorial-card hash, increment views atomically, update the title independently, and set a TTL.
One important caution
Do not call `HGETALL` on an unbounded huge hash for every request. Fetch required fields and monitor cardinality.
Redis — Hashes — Redis