Sets in Redis

From the Redis cheat sheet · Data Structures · verified Jul 2026

Sets

Unordered collections of unique strings

bash
# Add members
SADD myset "member1"
SADD myset "member2"

# Check membership
SISMEMBER myset "member1"

# Get all members
SMEMBERS myset

# Set operations
SUNION set1 set2       # Union
SINTER set1 set2       # Intersection
SDIFF set1 set2        # Difference
🎯 Guarantees unique members
⚡ O(1) add, remove, and check
🔄 Powerful set operations (union, intersection)
🎲 Random member selection support

More Redis tasks

Back to the full Redis cheat sheet