SUNION command in redis

SUNION key1 key2 ... keyN

Return the members of a set resulting from the union of all the sets hold at the specified keys.

Like in LRANGE the result is sent to the client as a multi-bulk reply.

TIME COMPLEXITY: O(N) where N is the total number of elements in all the provided sets

Note: None-xisting keys are considered empty sets.

RETURN VALUE: Multi bulk reply, specifically the list of common elements.

Syntax:

SUNION key1 key2 ... keyN

Example

redis:6379> SADD myrediKey hello redis tutorial
(integer) 3
redis:6379> SADD myredisKey2 hello java
(integer) 2
redis:6379> SUNION myrediKey myredisKey2
1) "hello"
2) "tutorial"
3) "redis"
4) "java"

Output

1) "hello"

2) "tutorial"

3) "redis"

4) "java"


No comments:

Post a Comment