当前位置:网站首页>006_ redis_ Sortedset type
006_ redis_ Sortedset type
2022-04-23 02:08:00 【_ yummy_】
006_redis_SortedSet type
1、 It's a sortable set aggregate , And java Medium treeset similar . But the underlying data structure is very different .
- SortedSet Each element in the has a score Properties of , Can be based on score Attribute to sort elements
- The underlying implementation is a jump table (SkipList) Add hash surface
2、SortedSet Have the characteristics of
- disorder
- Element is not repeatable
- Fast query speed
summary : because SortedSet SORTABILITY of , Often used to implement functions such as ranking boards .
3、SortedSet Common types of commands
- ZADD: Add one or more elements
- ZREM: Delete a specified element
- ZSCORE: Gets the amount of the specified element in the collection score value
- ZRANK: Gets the sort of the specified element
- ZCARD: Get the number of elements in the collection
- ZCOUNT: Statistics score The number of all elements whose values are within a given range
- ZINCREBY: Specified element self increment
- ZRANGE: according to score After sorting , Get the elements within the specified ranking range
- ZDIFF、ZINTER、ZUNION: Difference set 、 intersection 、 Combine
Be careful : All rankings are in ascending order by default , If you need to set the descending operation , Need to be in Z Add later REV that will do . such as :ZREVRANK
(1) Test practice
127.0.0.1:6379> zadd stus 85 jack 89 lucy 82 rose 95 tom 78 jerry 76 Miles
(integer) 6
127.0.0.1:6379> zrem stus tom
(integer) 1

- obtain rose The ranking of students
The ranking returned is from 0 At the beginning .
127.0.0.1:6379> zrank stus rose
(integer) 2
127.0.0.1:6379> zrevrank stus rose
(integer) 2
- Inquire about 80 How many people are there
127.0.0.1:6379> zcount stus 0 80
(integer) 2
- to Rose Classmate plus 2 branch
127.0.0.1:6379> zincrby stus 2 rose
"84"

- Find out the top three students ( Default ascending order , It needs to be reversed rev)
127.0.0.1:6379> zrevrange stus 0 2
1) "lucy"
2) "jack"
3) "rose"
- Find out the results 80 All the students below
127.0.0.1:6379> zrangebyscore stus 0 80
1) "Miles"
2) "jerry"
版权声明
本文为[_ yummy_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230202506736.html
边栏推荐
- Is the availability of proxy IP equal to the efficiency of proxy IP?
- Log4j2 configuration
- How to classify proxy IP?
- 中金财富跟中金公司是一家公司吗,安全吗
- Leetcode46 Full Permutation
- What is a makefile file?
- 每日一题(2022-04-22)——旋转函数
- 006_redis_SortedSet类型
- 都是做全屋智能的,Aqara和HomeKit到底有什么不同?
- Go language ⌈ mutex and state coordination ⌋
猜你喜欢

Introduction to micro build low code zero Foundation (lesson 2)

Under the pressure of sales, domestic mobile phones began to reduce prices, but they haven't put down their final face

一加一为什么等于二

Shardingsphere read write separation

Lane cross domain problem

Dynamic memory management

011_RedisTemplate操作Hash

Network jitter tool clumsy

Applet canvas canvas half ring

What categories do you need to know before using proxy IP?
随机推荐
浅析静态代理ip的三大作用。
浅析一下隧道代理IP的优缺点。
001_redis设置存活时间
Arduino esp8266 network upgrade OTA
JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
What are the test steps of dynamic proxy IP?
BGP服务器在什么业务场景会被用到?
What is BGP server and what are its advantages?
What categories do you need to know before using proxy IP?
[NK] Niuke monthly race 48 D
Why is one plus one equal to two
How to choose a good dial-up server?
Flink real-time data warehouse project - Design and implementation of DWS layer
[leetcode daily question] 396 Rotation function
Applet canvas canvas half ring
Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
Log4j2 configuration
009_Redis_RedisTemplate入门
Makefile文件是什么?
中金财富跟中金公司是一家公司吗,安全吗