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

Redis Sunion Command

Redis Sunion Command

Redis Set

The Redis Sunion command returns the union of the given sets. A non-existent set key is treated as an empty set.

Syntax

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



redis 127.0.0.1:6379> SUNION KEY KEY1..KEYN

Available Version

= 1.0.0

Return Value

A list of the union members.

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> SUNION key1 key2

1) "a"

2) "c"

3) "b"

4) "e"

5) "d"

redis> 

Redis Set