Redis SUNIONSTORE命令

作者:袖梨 2026-08-07

Redis SUNIONSTORE 命令类似于 SUNION 命令,但它将结果保存到 destination 集合,而不是简单地返回结果集。如果 destination 已经存在,则将其覆盖。

注意:destination 可以是 key 本身。

Redis SUNIONSTORE命令

可用版本

SUNIONSTORE 命令可用版本:>= 1.0.0

语法

Redis SUNIONSTORE 命令的基本语法如下:
SUNIONSTORE destination key [key ...]   

返回值

结果集中的元素数量。

命令演示

127.0.0.1:6379> SADD website www.biancheng.net www.baidu.com www. #添加一个集合成员(integer) 2127.0.0.1:6379> SADD site git python svn docker(integer) 4127.0.0.1:6379> SUNIONSTORE mysite site website(integer) 6127.0.0.1:6379> SMEMBERS mysite #将结果存储在一个目标集合mysite1) "git"2) "python"3) "docker"4) "svn"5) "www.baidu.com"6) "www.biancheng.net"

相关文章

精彩推荐