Redis Sunion 命令返回给定集合的并集。不存在的集合 key 被视为空集。
redis Sunion 命令基本语法如下:
- redis 127.0.0.1:6379> SUNION KEY KEY1..KEYN
>= 1.0.0
并集成员的列表。
- redis 127.0.0.1:6379> SADD myset1 "hello"
- (integer) 1
- redis 127.0.0.1:6379> SADD myset1 "world"
- (integer) 1
- redis 127.0.0.1:6379> SADD myset1 "bar"
- (integer) 1
- redis 127.0.0.1:6379> SADD myset2 "hello"
- (integer) 1
- redis 127.0.0.1:6379> SADD myset2 "bar"
- (integer) 1
- redis 127.0.0.1:6379> SUNION myset1 myset2
- 1) "bar"
- 2) "world"
- 3) "hello"
- 4) "foo"