Database / REDIS
What is a Redis Set data type used for?
A Set stores an unordered collection of unique strings — no duplicates are allowed, and there's no concept of order or position the way a List has. Its core value is fast membership testing and set algebra: checking whether an item exists, and combining multiple sets via union, intersection, or difference.
SADD tags:post123 "redis" "database" "nosql" SISMEMBER tags:post123 "redis" # membership check, O(1) SINTER tags:post123 tags:post456 # intersection of two sets SCARD tags:post123 # count of members
Typical use cases include tagging (a post's set of tags), tracking unique visitors or unique events (adding a user ID to a set naturally de-duplicates), and relationship queries like "users who like both A and B" via SINTER. Because membership checks and set operations run in close to constant or linear time relative to set size rather than requiring a full scan, Sets are a common choice whenever the core question is "is X in this collection" or "what do these two collections have in common."
More Related questions...
