Redis SUNIONSTORE命令
Redis SUNIONSTORE命令被用來存儲,該組由所有的給定集合的並集所得的成員。不存在鍵被認為是空集。
返回值
返回整數,所得集合元素的數量。
語法
redis SUNIONSTORE命令的基本語法如下所示:
redis 127.0.0.1:6379> SUNIONSTORE DESTINATION KEY KEY1..KEYN
實例
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> SUNIONSTORE myset myset1 myset2 (integer) 1 redis 127.0.0.1:6379> SMEMBERS myset 1) "bar" 2) "world" 3) "hello" 4) "foo"