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

Redis data manipulation-- unordered set

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

| an ordered collection, like a collection, can contain any number of different elements. Unlike a collection, each element of an ordered collection is associated with a floating point score, and an ordered collection arranges the elements of an ordered collection in order from smallest to largest according to the score. Although each element in an ordered set must be different, there is no limit to the score of the element. in other words, the score of two different elements can be the same. | basic operation-add element zadd key score element [[score element] [score element].] # add any number of elements to the ordered collection according to the given score and elements, and the return value of the command is the number of elements successfully added. Delete element zrem key element [element...] # removes the specified elements from the ordered collection and the scores associated with these elements, and the command returns the number of elements that were successfully deleted. -- return the score of the element zscore key element returns the score of the specified element in the ordered set-- increase or decrease the score of the element zincrby key increment element # plus the increment increment of the element specified in the ordered set, and the command returns the score of the element after the operation is performed. # No response to the zdecrby command, but you can reduce the score by setting increment to a negative number-- return the number of elements zcard key # returns the number of elements contained in the ordered set-- return the ranking of the elements zrank key element # returns the ranking of the specified elements in the ordered collection, where the ranking is calculated according to the element ed score from small to large. # ranking starts at 0-returns the reverse ranking of elements zrevrank key member # returns the reverse ranking of members in an ordered collection, where the ranking is calculated from large to small according to the score of the element. # ranking starts at 0 | score range operation-- gets the ascending element zrange key start stop [withscores] # within the specified index range returns the ordered collection. In the case of sorting elements in ascending order from smallest to largest (ascending order), # all elements in the range from # index start to index stop # both indexes can be positive or negative, when the withscores option is given The command returns both the element and the score-- gets the descending element zrevrange key start stop [withscores] # within the specified index range and returns the ordered collection indexing all elements from start to stop in descending order by score. Both indexes can be positive or negative, and when the withscores option is given, the command returns both the element and the score. -- gets the ascending element zrangebyscore key min max [withscores] [limit off set count] # within the specified score range and returns an ordered collection of all elements whose scores are within the range of min and man when the elements are sorted in ascending order. # when the withscores option is given, the element and score are returned together. Given the limit option, you can specify how many elements to skip in the returned result set through the offset parameter, while the count parameter is used to specify the number of elements returned. -- get the descending element zrevrangebyscore key min max [withscores] [limit offset count] # within the specified score range and return the ordered collection. If the elements are sorted in descending order by score, all elements with scores within the range of min and man are returned. Given the withscores option, both the element and the score will be returned. Given the limit option, you can specify how many elements to skip in the returned result set through the offset parameter, while the count parameter is used to specify the number of elements returned. -- calculate the number of elements within a given score range zcount key min max # returns the number of elements in an ordered collection with scores in the range of min and man in ascending order. Remove elements in ascending order within the specified ranking range zremrangebyrank key start stop # removes all elements in the specified ranking range when the elements are arranged in ascending order. # Rank range can use positive and negative numbers-remove ascending elements within a specified score range zremrangebyscore key min max # remove an ordered collection All elements with scores within the range of min and max (music ranking version rank_list.py), (implementation of API for page flipping program paging.py) | set operation-Compute union and intersection zunionstore destkey numkeys key [key...] # calculate union zinterstore destkey numkeys key [key...] # calculate intersection calculation results will be stored in destkey, and the command returns the cardinality of the result set The numkeys parameter specifies the number of ordered sets to be calculated, key [key...] Specifies the ordered collections in which calculations are made. (realize weekly, monthly and annual lists)

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

Database

Wechat

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

12
Report