栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

学大数据小胖的第四十天

学大数据小胖的第四十天

SortedSet
127.0.0.1:6379> help zadd

  ZADD key [NX|XX] [GT|LT] [CH] [INCR] score member [score member ...]
  summary: Add one or more members to a sorted set, or update its score if it already exists
  since: 1.2.0
  group: sorted_set

127.0.0.1:6379> zadd fruits 3.2 香蕉
(integer) 1
127.0.0.1:6379> zadd fruits 2.0 西瓜
(integer) 1
127.0.0.1:6379> zadd fruits 4.0 石榴 7.0 梨子 6.8 芒果
(integer) 3
127.0.0.1:6379> zrank fruits 西瓜
(integer) 0
127.0.0.1:6379> zrank fruits 石榴
(integer) 2
127.0.0.1:6379> zrange fruits 1 3
1) "xe9xa6x99xe8x95x89"
2) "xe7x9fxb3xe6xa6xb4"
3) "xe8x8ax92xe6x9ex9c"
127.0.0.1:6379> zrange fruits 1 3 withscores
1) "xe9xa6x99xe8x95x89"
2) "3.2000000000000002"
3) "xe7x9fxb3xe6xa6xb4"
4) "4"
5) "xe8x8ax92xe6x9ex9c"
6) "6.7999999999999998"
127.0.0.1:6379> zrevrange fruits 1 3 withscores
1) "xe8x8ax92xe6x9ex9c"
2) "6.7999999999999998"
3) "xe7x9fxb3xe6xa6xb4"
4) "4"
5) "xe9xa6x99xe8x95x89"
6) "3.2000000000000002"
127.0.0.1:6379> zrem fruits 石榴
(integer) 1
127.0.0.1:6379> zrevrange fruits 0 -1
1) "xe6xa2xa8xe5xadx90"
2) "xe8x8ax92xe6x9ex9c"
3) "xe9xa6x99xe8x95x89"
4) "xe8xa5xbfxe7x93x9c"
127.0.0.1:6379> zadd fruits 3 西瓜
(integer) 0"
127.0.0.1:6379> zrevrange fruits 0 -1 withscores
1) "xe6xa2xa8xe5xadx90"
2) "7"
3) "xe8x8ax92xe6x9ex9c"
4) "6.7999999999999998"
5) "xe9xa6x99xe8x95x89"
6) "3.2000000000000002"
7) "xe8xa5xbfxe7x93x9c"
8) "3"
127.0.0.1:6379> zadd fruits 3.2 西瓜
(integer) 0
127.0.0.1:6379> zrevrange fruits 0 -1 withscores
1) "xe6xa2xa8xe5xadx90"
2) "7"
3) "xe8x8ax92xe6x9ex9c"
4) "6.7999999999999998"
5) "xe9xa6x99xe8x95x89"
6) "3.2000000000000002"
7) "xe8xa5xbfxe7x93x9c"
8) "3.2000000000000002"
127.0.0.1:6379> zscore fruits 西瓜
"3.2000000000000002"
127.0.0.1:6379> zincrby fruits -1.2 西瓜
"2"
127.0.0.1:6379> zincrby fruits 2.2 香蕉
"5.4000000000000004"
127.0.0.1:6379> zrangebyscore fruits 3 6
1) "xe9xa6x99xe8x95x89"
127.0.0.1:6379> zrangebyscore fruits 3 6 withscores
1) "xe9xa6x99xe8x95x89"
2) "5.4000000000000004"
127.0.0.1:6379> zrangebyscore fruits 3 10
1) "xe9xa6x99xe8x95x89"
2) "xe8x8ax92xe6x9ex9c"
3) "xe6xa2xa8xe5xadx90"
127.0.0.1:6379> zrangebyscore fruits 3 10 limit 1 2
1) "xe8x8ax92xe6x9ex9c"
2) "xe6xa2xa8xe5xadx90"
127.0.0.1:6379> zrange fruits 0 -1
1) "xe8xa5xbfxe7x93x9c"
2) "xe9xa6x99xe8x95x89"
3) "xe8x8ax92xe6x9ex9c"
4) "xe6xa2xa8xe5xadx90"
127.0.0.1:6379> zremrangebyrank fruits 1 2
(integer) 2
127.0.0.1:6379> zrange fruits 0 -1
1) "xe8xa5xbfxe7x93x9c"
2) "xe6xa2xa8xe5xadx90"
127.0.0.1:6379> zcard fruits
(integer) 2
127.0.0.1:6379> zcount fruits 2 3
(integer) 1
127.0.0.1:6379> zcount fruits 3 10
(integer) 1
127.0.0.1:6379> zcount fruits 10 100
(integer) 0
127.0.0.1:6379> zadd scores1 70 tom 80 peter 60 john
(integer) 3
127.0.0.1:6379> zrange scores1 0 -1
1) "john"
2) "tom"
3) "peter"
127.0.0.1:6379> zrange scores1 0 -1 withscores
1) "john"
2) "60"
3) "tom"
4) "70"
5) "peter"
6) "80"
127.0.0.1:6379> zadd score2 90 peter 60 ben
(integer) 2
127.0.0.1:6379> zrange score2 0 -1 withscores
1) "ben"
2) "60"
3) "peter"
4) "90"
127.0.0.1:6379> zunionstore scores-all 2 scores1 score2
(integer) 4
127.0.0.1:6379> zrange scores-all 0 -1 withscores
1) "ben"
2) "60"
3) "john"
4) "60"
5) "tom"
6) "70"
7) "peter"
8) "170"
127.0.0.1:6379> zunionstore scores-all1 2 scores1 score2 aggregate sum
(integer) 4
127.0.0.1:6379> zrange scores-all1 0 -1 withscores
1) "ben"
2) "60"
3) "john"
4) "60"
5) "tom"
6) "70"
7) "peter"
8) "170"
127.0.0.1:6379> zunionstore scores-all2 2 scores1 score2 aggregate max
(integer) 4
127.0.0.1:6379> zrange scores-all2 0 -1 withscores
1) "ben"
2) "60"
3) "john"
4) "60"
5) "tom"
6) "70"
7) "peter"
8) "90"
127.0.0.1:6379> zunionstore scores-all3 2 scores1 score2 aggregate min
(integer) 4
127.0.0.1:6379> zrange scores-all3 0 -1 withscores
1) "ben"
2) "60"
3) "john"
4) "60"
5) "tom"
6) "70"
7) "peter"
8) "80"
127.0.0.1:6379> zunionstore score-all1 2 scores1 score2 weights 2 0.5 aggregate sum
(integer) 4
127.0.0.1:6379> zrange score-all1 0 -1 withscores
1) "ben"
2) "30"
3) "john"
4) "120"
5) "tom"
6) "140"
7) "peter"
8) "205"
127.0.0.1:6379> zunionstore score-all1 2 scores1 score2 weights 2 0.5 aggregate max
(integer) 4
127.0.0.1:6379> zrange score-all1 0 -1 withscores
1) "ben"
2) "30"
3) "john"
4) "120"
5) "tom"
6) "140"
7) "peter"
8) "160"
127.0.0.1:6379> zunionstore score-all1 2 scores1 score2 weights 2 0.5 aggregate min
(integer) 4
127.0.0.1:6379> zrange score-all1 0 -1 withscores
1) "ben"
2) "30"
3) "peter"
4) "45"
5) "john"
6) "120"
7) "tom"
8) "140"
127.0.0.1:6379> zunionstore score-all1 2 scores1 score2 weights 2 2 aggregate sum
(integer) 4
127.0.0.1:6379> zrange score-all1 0 -1 withscores
1) "ben"
2) "120"
3) "john"
4) "120"
5) "tom"
6) "140"
7) "peter"
8) "340"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2 
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "170"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2 aggregate sum
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "170"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2 aggregate min
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "80"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2 aggregate max
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "90"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2  weights 2 0.5  aggregate sum
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "205"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2  weights 2 0.5  aggregate max
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "160"
127.0.0.1:6379> zinterstore score-all3 2 scores1 score2  weights 2 0.5  aggregate min
(integer) 1
127.0.0.1:6379> zrange score-all3 0 -1 withscores
1) "peter"
2) "45"

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/773757.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号