ZUNIONSTORE command in redis

ZUNIONSTORE destination numkeys key [key ...]

Adds multiple sorted sets and stores the resulting sorted set in a new key

Redis ZUNIONSTORE command calculates the union of numkeys sorted sets given by the specified keys, and stores the result in the destination.

It is mandatory to provide the number of input keys (numkeys) before passing the input keys and the other (optional) arguments.

RETURN VALUE

It returns the number of elements in the resulting sorted set at the destination.

Syntax:

ZUNIONSTORE destination numkeys key [key ...]

Example

redis:6379> ZADD mykey 0 A 2 C 3 D 1 E
(integer) 4
redis:6379> ZADD mykey1 0 A 2 C 3 D 11 E 12 F
(integer) 5
redis:6379> ZUNIONSTORE dstkey 2 mykey mykey2
(integer) 4

Output

4

No comments:

Post a Comment