Redis Sunionstore 命令

约 504 字 更新于 2026-11-18 5iyo.com

Redis Sunionstore 命令

Redis Sunionstore 命令将给定集合的并集存储在指定的集合 destination 中。如果 destination 已经存在,则将其覆盖。

语法

redis Sunionstore 命令基本语法如下:


SUNIONSTORE destination key [key ...]

可用版本

>= 1.0.0

返回值

结果集中的元素数量。

实例


redis> SADD key1 "a"

(integer) 1

redis> SADD key1 "b"

(integer) 1

redis> SADD key1 "c"

(integer) 1

redis> SADD key2 "c"

(integer) 1

redis> SADD key2 "d"

(integer) 1

redis> SADD key2 "e"

(integer) 1

redis> SUNIONSTORE key key1 key2

(integer) 5

redis> SMEMBERS key

1) "c"

2) "b"

3) "e"

4) "d"

5) "a"

redis>