Hashes, Lists, Sets, Sorted Sets, and Redis Data Structures
Use Redis as more than a string store by learning the built-in data structures that enable richer application patterns.
Inside this chapter
- Why Data Structures Make Redis Special
- Hashes
- Lists
- Sets and Sorted Sets
- Real Example
Series navigation
Study the chapters in order for the clearest path from Redis basics to advanced cache architecture, operations, and distributed-system design. Use the navigation at the bottom to move smoothly through the full tutorial series.
Why Data Structures Make Redis Special
Redis is often called a data structure server because it supports multiple structured value types, not only plain strings. This lets developers model useful application behavior efficiently.
Hashes
HSET user:42 name "Asha" email "asha@example.com"
HGET user:42 email
Hashes are useful for grouped fields such as user profiles, configuration objects, or counters per entity.
Lists
LPUSH jobs "task-1"
RPOP jobs
Lists can support queue-like processing, ordered items, or activity streams.
Sets and Sorted Sets
Sets are useful when uniqueness matters. Sorted sets add ordering through scores, which makes them powerful for ranking and time-based patterns.
ZADD leaderboard 1200 "player-1"
ZRANGE leaderboard 0 -1 WITHSCORES Real Example
An online game may use hashes for player profiles, sets for unlocked achievements, lists for event queues, and sorted sets for leaderboards. Redis data structures let one platform support many kinds of state efficiently.