SADD / SMEMBERS / SINTER

Set commands manage unordered collections of unique strings. SADD adds members. SMEMBERS returns all members. Set operations include SINTER (intersection), SUNION, and SDIFF.

Syntax

redis
SADD key member [member ...]
SMEMBERS key
SINTER key [key ...]

Example

redis
SADD tags:post1 "redis" "database"
SADD tags:post2 "redis" "python"
SINTER tags:post1 tags:post2
# 1) "redis"
SUNION tags:post1 tags:post2
SISMEMBER tags:post1 "redis"
# (integer) 1