Redis Zunionstore command
The Redis Zunionstore command computes the union of one or more given sorted sets. The number of given keys must be specified via the numkeys parameter, and the union (result set) is stored in destination.
By default, the score of a member in the result set is the sum of that member's scores across all given sets.
Syntax
The basic syntax of the redis Zunionstore command is as follows:
redis 127.0.0.1:6379> ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
Available Version
= 2.0.0
Return Value
The number of members in the result set saved to destination.
Example
redis
ZADD zset1
1
"one"
(
integer
)
1
redis
ZADD zset1
2
"two"
(
integer
)
1
redis
ZADD zset2
1
"one"
(
integer
)
1
redis
ZADD zset2
2
"two"
(
integer
)
1
redis
ZADD zset2
3
"three"
(
integer
)
1
redis
ZUNIONSTORE out
2
zset1 zset2 WEIGHTS
2
3
(
integer
)
3
redis
ZRANGE out
0
-1
WITHSCORES
1
)
"one"
2
)
"5"
3
)
"three"
4
)
"9"
5
)
"two"
6
)
"10"
redis
