union

UK[ˈju:niən] US[ˈjunjən]

n. Alliance, alliance; association, union; union, unity

adj. The plural of unions

: unions

store

##UK[stɔ:(r)] US[stɔr, stor]

n. Store; storage; warehouse; large amount

v. Storage; (in a computer) storage

Third person singular: stores Plural: stores Present participle: storing Past tense: stored past participle: stored

redis ZUNIONSTORE command syntax

Function:Calculate the union of one or more given ordered sets, where the number of given keys must be specified with the numkeys parameter, and store the union (result set) in destination .

By default, the score value of a member in the result set is the sum of the score values of all members in the given set.

Syntax:ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]

Available versions:>= 2.0.0

Time complexity:O(N) O(M log(M)), N is the cardinality of a given ordered set The sum of , M is the cardinality of the result set.

Returns:The cardinality of the result set saved to destination.

redis ZUNIONSTORE command example

redis> ZRANGE programmer 0 -1 WITHSCORES 1) "peter" 2) "2000" 3) "jack" 4) "3500" 5) "tom" 6) "5000" redis> ZRANGE manager 0 -1 WITHSCORES 1) "herry" 2) "2000" 3) "mary" 4) "3500" 5) "bob" 6) "4000" redis> ZUNIONSTORE salary 2 programmer manager WEIGHTS 1 3 # 公司决定加薪。。。除了程序员。。。 (integer) 6 redis> ZRANGE salary 0 -1 WITHSCORES 1) "peter" 2) "2000" 3) "jack" 4) "3500" 5) "tom" 6) "5000" 7) "herry" 8) "6000" 9) "mary" 10) "10500" 11) "bob" 12) "12000"