Data Types: Structures That Solve Problems
Harry
· 13 Sep 2026
· 1 views
Lists
LPUSH queue task-1 # push to head
RPUSH queue task-2 # push to tail
LRANGE queue 0 -1 # all items in order
LPOP queue # pop from headLists make fifo queues and recent-activity feeds.
Sets
SADD online user-42
SISMEMBER online user-42 # 1
SINTER group1 group2 # common users
SCARD online # countSets handle uniqueness, tags and membership checks.
Sorted Sets
ZADD scores 100 alice 200 bob
ZREVRANGE scores 0 2 WITHSCORES # top 3
ZINCRBY scores 50 alice # incremental update
ZSCORE scores aliceSorted sets power leaderboards, queues with priority and rate limiting by score.
Hashes
HSET user:42 name "Alice" role "admin"
HGET user:42 name
HGETALL user:42
HINCRBY user:42 "visits" 1Hashes store objects as fields, and partial updates touch no extra payload.
Key Points
- Lists queue; sets deduplicate; hashes model objects.
- Sorted sets rank by score atomically.
- Every type has atomic operations for counters.
- Pick the type that fits the read/write pattern.