W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]
例如:
127.0.0.1:6379> zrangebyscore votes -inf inf withscores
1) "sina"
2) "1"
3) "google"
4) "5"
5) "baidu"
6) "10"
127.0.0.1:6379> zrangebyscore visits -inf inf withscores
1) "baidu"
2) "1"
3) "google"
4) "5"
5) "sina"
6) "10"
127.0.0.1:6379> zunionstore award 2 visits votes weights 1 2 aggregate sum
(integer) 3
127.0.0.1:6379> zrangebyscore award -inf inf withscores
1) "sina"
2) "12"
3) "google"
4) "15"
5) "baidu"
6) "21"
一個(gè)小技巧是如果需要對(duì)評(píng)分進(jìn)行倍加,則使用如下的方法:
127.0.0.1:6379>zrangebyscore visits -inf inf withscores
1) "baidu"
2) "1"
3) "google"
4) "5"
5) "sina"
6) "10"
127.0.0.1:6379>zunionstore visits 1 visits weights 2
(integer) 3
127.0.0.1:6379>zrangebyscore visits -inf inf withscores
1) "baidu"
2) "2"
3) "google"
4) "10"
5) "sina"
6) "20"
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: