Build the mental model
Lists preserve insertion order and support push/pop at both ends, making them useful for queues, stacks, and bounded recent history. Sets store unordered unique members and support membership, intersection, union, and difference. When jobs need acknowledgments and recovery, prefer Streams over a simple list pop.
Connect it to a real scenario
Store user 42's recent tutorial IDs in a list and cap it at 20 with `LTRIM`. Store tutorial tags and user interests in sets, then use `SINTER` to find recommendation overlap.
Try the working example
LPUSH recent:user:42 tutorial:7 tutorial:9 tutorial:12
LTRIM recent:user:42 0 19
LRANGE recent:user:42 0 -1
SADD interests:user:42 database backend redis
SADD tags:tutorial:12 redis database caching
SISMEMBER tags:tutorial:12 redis
SINTER interests:user:42 tags:tutorial:12You create a bounded recent list and calculate unique interest overlap.5-minute try-it
Cap a recently viewed list at five, observe duplicate behavior, and run union/difference on two sets.
One important caution
Lists do not enforce uniqueness. Use a set or a coordinated list-plus-set design when uniqueness matters.
Redis — Data Types — Redis