Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Sunionstore Command

Redis Sunionstore Command

Redis Set

The Redis Sunionstore command stores the union of the given sets in the specified destination set. If destination already exists, it overwrites it.

Syntax

The basic syntax of the redis Sunionstore command is as follows:



SUNIONSTORE destination key [key ...]

Available Version

= 1.0.0

Return Value

The number of elements in the result set.

Example



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> 

Redis Set