Redis SUNIONSTORE 命令用于存储所有给定集合的并集产生的集合元素。不存在的键被认为是空集。
SUNIONSTORE - 返回值
返回整数,输出集中的元素数量。
SUNIONSTORE - 语法
以下是Redis SUNIONSTORE 命令的基本语法。
redis 127.0.0.1:6379> SUNIONSTORE DESTINATION KEY KEY1..KEYN
SUNIONSTORE - 例
redis 127.0.0.1:6379> SADD myset1 "hello" (integer) 1 redis 127.0.0.1:6379> SADD myset1 "Learnfk" (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> SUNIONSTORE myset myset1 myset2 (integer) 1 redis 127.0.0.1:6379> SMEMBERS myset 1) "bar" 2) "Learnfk" 3) "hello" 4) "foo"