Redis - Set Sunion Command


Advertisements

Redis SUNION command is used to get the members of the set resulting from the union of all the given sets. Keys that do not exist are considered to be empty sets.

Return Value

Array reply, list with members of the resulting set.

Syntax

Following is the basic syntax of Redis SUNION command.

redis 127.0.0.1:6379> SUNION KEY KEY1..KEYN

Example

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> SUNION myset1 myset2 
1) "bar" 
2) "world" 
3) "hello" 
4) "foo" 
redis_sets.htm
Advertisements