1. 程式人生 > >Redis基礎之有序集合

Redis基礎之有序集合

127.0.0.1:6379> zrange sortedSet1 0 -1 WITHSCORES
1) "a"
2) "1"
3) "b"
4) "2"
127.0.0.1:6379> zrange sortedSet2 0 -1 WITHSCORES
1) "a"
2) "20"
3) "b"
4) "20"
127.0.0.1:6379> zinterstore sortedSets 2 sortedSet1 sortedSet2
(integer) 2
127.0.0.1:6379> zrange sortedSets 0 -1 WITHSCORES
1) "a"
2) "21"
3) "b"
4) "22"
127.0.0.1:6379> zinterstore sortedSets 2 sortedSet1 sortedSet2 AGGREGATE MIN
(integer) 2
127.0.0.1:6379> zrange sortedSets 0 -1 WITHSCORES
1) "a"
2) "1"
3) "b"
4) "2"
127.0.0.1:6379> zinterstore sortedSets 2 sortedSet1 sortedSet2 AGGREGATE MAX
(integer) 2
127.0.0.1:6379> zrange sortedSets 0 -1 WITHSCORES
1) "a"
2) "20"
3) "b"
4) "20"
127.0.0.1:6379> zinterstore sortedSets 2 sortedSet1 sortedSet2 WEIGHTS 1 0.5
(integer) 2
127.0.0.1:6379> zrange sortedSets 0 -1 WITHSCORES
1) "a"
2) "11"
3) "b"
4) "12"