如果 count 为正数,且小于集合基数,那么命令返回一个包含 count 个元素的数组,数组中的元
素各不相同。如果 count 大于等于集合基数,那么返回整个集合。
如果 count 为负数,那么命令返回一个数组,数组中的元素可能会重复出现多次,而数组的长度
为 count 的绝对值。
其他操作:
sscan key cursor [MATCH pattern] [COUNT count]: 用于增量地迭代set cursor是 迭代的开始索引,第一次为0,迭代中第一行返回值为下一次继续迭代的索引,如果为0代表迭代完毕 Match pattenrn是 匹配set中元素的模式 count count是此次迭代的数量
smove source destination member:将 member 元素从 source 集合移动到 destination 集合。如果 source 集合不存在或不包含指定的 member 元素,则 SMOVE 命令不执行任何操作,仅返回 0 。否则, member 元素从 source 集合中被移除,并添加到 destination 集合中去。
sdiff key [key ...]:返回给定集合之间的差集
sdiffstore destination key [key ...]:返回给定集合之间的差集,并存储到destination中,如果 destination 集合已经存在,则将其覆盖。destination 可以是 key 本身。
sinter key [key ...]:返回所有给定集合的交集
sinter destination key [key ...]:返回给定集合之间的交集,并存储到destination中,如果 destination 集合已经存在,则将其覆盖。destination 可以是 key 本身。
sismember key member:判断 member 元素是否集合 key 的成员。
srem key member [member ...]:移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略。当 key 不是集合类型,返回一个错误。
sunion key [key…] :返回所有给定集合的并集。不存在的 key 被视为空集。
sunionstore destination key [key…] :返回所有给定集合的并集,不存在的 key 被视为空集,将返回的结果保存到 destination 集合.如果 destination 已经存在,则将其覆盖。destination 可以是 key 本身。
补充:
redis是有数据类型的,操作会检测数据类型,除去一些能“覆盖”原变量,忽略原变量类型的操作,其他操作遇到不符合的类型都会报错











