Latest web development tutorials

RedisのZunionstoreコマンド

Redisのは、順序セット(ソートセット)

RedisのZunionstoreコマンドキーパラメータの与えられた数はnumkeysに指定する必要がある計算1を与えられた以上のセットを注文して設定し、先に格納された組合(結果セット)。

デフォルトでは、結果セットポイント値は、値とスコアの与えられたセットの下にあるすべてのメンバーのメンバーです。

文法

次のようにRedisのZunionstore基本的なコマンドの構文は次のとおりです。

redis 127.0.0.1:6379> ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]

利用可能なバージョン

> = 2.0.0

戻り値

結果セットの先のメンバーの数に保存します。

redis 127.0.0.1:6379> ZRANGE programmer 0 -1 WITHSCORES
1) "peter"
2) "2000"
3) "jack"
4) "3500"
5) "tom"
6) "5000"

redis 127.0.0.1:6379> ZRANGE manager 0 -1 WITHSCORES
1) "herry"
2) "2000"
3) "mary"
4) "3500"
5) "bob"
6) "4000"

redis 127.0.0.1:6379> ZUNIONSTORE salary 2 programmer manager WEIGHTS 1 3   # 公司决定加薪。。。除了程序员。。。
(integer) 6

redis 127.0.0.1:6379> 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"

Redisのは、順序セット(ソートセット)