Redis 教程 Redis Sunionstore 命令

vicente · 2022-03-03 15:05:14 · 热度: 7

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>

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册