In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
# introduction to sort set (ordered set)
It has a weight parameter score more than set, so that the elements in the collection can be arranged in order by score, such as a sorted set that stores the scores of the whole class, whose collection value can be the student number of students, and score can be its examination score, so that when the data is inserted into the collection, it has been sorted naturally.
# Common commands
# create an ordered collection
> zadd set2 12 "aaa" # 12 is a score
(integer) 1
> zadd set2 30 "linux"
(integer) 1
> zadd set2 7 "python"
(integer) 1
> zadd set2 13 "nosql"
(integer) 1
# Delete elements
Zrem zseta 222Delete the specified element
Zremrangebyrank zseta 0 2 / / deletes the elements in the index range 0-2, sorting by score forward
Zremrangebyscore zseta 1 10 / / Delete elements with scores ranging from 1 to 10
# display elements
Zrank zseta 22 / / returns the index value of the element, which starts at 0 and is sorted forward by score
Zrevrank zseta 222ditto, except that it is sorted in reverse order of score
> zrange set2 0-1 # displays all elements in order
1) "python"
2) "aaa"
3) "nosql"
4) "linux"
> zrevrange set2 0-1 # reverse order
1) "linux"
2) "nosql"
3) "aaa"
4) "python"
Zrange zseta 0-1 withscores # can take a score
Zcard zseta / / returns the number of all elements in the collection
Zcount zseta 1 10 / / returns the number of elements with a score of 1-10
Zrangebyscore zseta 1 10 / / returns elements with a score of 1-10
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.