当前位置:网站首页>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
边栏推荐
- 假如404页面是这样的 | 每日趣闻
- Virtual serial port function of j-link V9 using skills
- 005_redis_set集合
- 小程序 读取文件
- 011_RedisTemplate操作Hash
- Multithreading technology core
- PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
- Flink real-time data warehouse project - Design and implementation of DWS layer
- Analyze the three functions of static proxy IP.
- OJ daily practice - Finish
猜你喜欢
浅析静态代理ip的三大作用。
[hands on learning] network depth v2.1 Sequence model
PHP & laravel & master several ways of generating token by API and some precautions (PIT)
007_Redis_Jedis连接池
Kubernetes cluster installation based on Kirin SP10 server version
一些使用代理IP的小技巧。
World Book Day 𞓜 a good book that technicians should not miss (it cutting-edge technology)
Want to experience homekit smart home? Why don't you take a look at this smart ecosystem
How does Axure set the content of the text box to the current date when the page is loaded
[assembly language] understand "stack" from the lowest point of view
随机推荐
Consider defining a bean of type 'com netflix. discovery. AbstractDiscoveryClientOptionalArgs‘
Realize linear regression with tensorflow (including problems and solutions in the process)
JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
Why is one plus one equal to two
Analyze the three functions of static proxy IP.
Is CICC fortune a company with CICC? Is it safe
Lane cross domain problem
Easyswool environment configuration
浅析一下隧道代理IP的优缺点。
Network jitter tool clumsy
leetcode:27. 移除元素【count remove小操作】
Esp32 message queue using FreeRTOS
【汇编语言】从最底层的角度理解“堆栈”
006_redis_jedis快速入门
89 régression logistique prédiction de la réponse de l'utilisateur à l'image de l'utilisateur
PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
Makefile文件是什么?
有哪些常见的代理ip问题?
EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
OJ daily practice - Finish