Redis SINTER命令

Redis SINTER命令所有指定集合交集后得到一组元素。键不存在被认为是空集。键是一个空集,将得到的集合也是空的(因为一个空集的交集总是产生一个空集)。

返回值

返回数组,列表与所得组的成员。

语法

Redis SINTER命令的基本语法如下所示:

redis 127.0.0.1:6379> SINTER KEY KEY1..KEYN 

例子

redis 127.0.0.1:6379> SADD myset "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset "foo"
(integer) 1
redis 127.0.0.1:6379> SADD myset "bar"
(integer) 1
redis 127.0.0.1:6379> SADD myset2 "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset2 "world"
(integer) 1
redis 127.0.0.1:6379> SINTER myset myset2
1) "hello"

上一篇: 下一篇: Redis环境安装配置