Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common command collation of Redis ordered collection types

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "Redis ordered set types of common commands collation", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Redis ordered collection types of common commands collation" it!

Redis common commands to sort out ordered collection types

Add elements

Zadd key score member [score member. ]

The zadd command is used to add an element and its score to the ordered collection, and if the element already exists, the score is replaced with the new score. The return value of the zadd command is the number of elements newly added to the collection (excluding pre-existing elements)

Get the score of the element

Zscore key member

Returns the score value as a member member, expressed as a string.

Get a list of elements ranked in a certain range

Zrange key start stop [withscores]

The zrange command returns all elements indexed from start to stop (including elements at both ends) in the order of element scores. The zrange command is very similar to the lrange command, such as the index starts at 0, and a negative number represents looking back and forward (- 1 represents the last element). If you need to score an element at the same time, you can add the widthscores parameter to the end of the zrange command

Note: if the scores of the two elements are the same, redis will follow the dictionary order (i.e. 0

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report