简介
- Redis Set(集合)
 - 命令特征:所有命令开始前都带有字母“S”
 - 使用场合:好友共同关注
增加
| 命令 | 解释 |
| —- | —- |
| SADD key member [member …] | 添加一个或者多个元素到集合(set)里 |
| SUNION key [key …] | 添加多个set元素 | 
删除
| 命令 | 
解释 | 
| SPOP key [count] | 
删除并获取一个集合里面的元素 | 
| SREM key member [member …] | 
从集合里删除一个或多个元素 | 
查询
| 命令 | 
解释 | 
| SCARD key | 
获取集合里面的元素数量 | 
| SDIFF key [key …] | 
获得队列不存在的元素 | 
| SDIFFSTORE destination key [key …] | 
获得队列不存在的元素,并存储在一个关键的结果集 | 
| SINTER key [key …] | 
获得两个集合的交集 | 
| SINTERSTORE destination key [key …] | 
获得两个集合的交集,并存储在一个关键的结果集 | 
| SISMEMBER key member | 
确定一个给定的值是一个集合的成员 | 
| SMEMBERS key | 
获取集合里面的所有元素 | 
| SRANDMEMBER key [count] | 
从集合里面随机获取一个元素 | 
修改
| 命令 | 
解释 | 
| SMOVE source destination member | 
移动集合里面的一个元素到另一个集合 | 
| SUNIONSTORE destination key [key …] | 
合并set元素,并将结果存入新的set里面 | 
| SSCAN key cursor [MATCH pattern] [COUNT count] | 
迭代set里面的元素 | 
其他
http://www.redis.cn/commands.html#set
help @set  SADD key member [member ...]  summary: Add one or more members to a set  since: 1.0.0  SCARD key  summary: Get the number of members in a set  since: 1.0.0  SDIFF key [key ...]  summary: Subtract multiple sets  since: 1.0.0  SDIFFSTORE destination key [key ...]  summary: Subtract multiple sets and store the resulting set in a key  since: 1.0.0  SINTER key [key ...]  summary: Intersect multiple sets  since: 1.0.0  SINTERSTORE destination key [key ...]  summary: Intersect multiple sets and store the resulting set in a key  since: 1.0.0  SISMEMBER key member  summary: Determine if a given value is a member of a set  since: 1.0.0  SMEMBERS key  summary: Get all the members in a set  since: 1.0.0  SMOVE source destination member  summary: Move a member from one set to another  since: 1.0.0  SPOP key [count]  summary: Remove and return one or multiple random members from a set  since: 1.0.0  SRANDMEMBER key [count]  summary: Get one or multiple random members from a set  since: 1.0.0  SREM key member [member ...]  summary: Remove one or more members from a set  since: 1.0.0  SSCAN key cursor [MATCH pattern] [COUNT count]  summary: Incrementally iterate Set elements  since: 2.8.0  SUNION key [key ...]  summary: Add multiple sets  since: 1.0.0  SUNIONSTORE destination key [key ...]  summary: Add multiple sets and store the resulting set in a key  since: 1.0.0