In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how php implements the Zset operation of Redis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Zset operation
/ / add one or more member elements and their score values to the ordered set. If a member is already a member of an ordered set, update the member's score value and ensure that the member is in the correct position by reinserting the member element. Fractional values can be integer values or double-precision floating-point numbers. $ret = $redis- > zAdd ('scores', 98,' English', 90, 'physics'); / / returns the members in the specified interval in the ordered set. Members are sorted incrementally by score value, and those with the same score value are sorted in lexicographic order. / / Parameter: the fourth parameter indicates whether to return the score value of each element. The default is false. $ret = $redis- > zRange ('scores', 0,-1, true); / / View all members of Zset and their respective score values / / return members in the specified interval in the ordered set. Members are sorted by decreasing scores, and those with the same values are sorted in reverse lexicographic order. $ret = $redis- > zReverseRange ('scores', 0,-1, true); / / returns the list of members in the specified score range in the ordered set, sorted by increasing scores, and those with the same values are sorted in lexicographical order. A closed interval is used by default. $ret = $redis- > zRangeByScore ('scores', 90,100, [' withscores'= > true]); / / returns the list of members in the specified score range in the ordered set, sorted by decreasing scores, and those with the same values are sorted in reverse order of lexicographic order. Note that when the interval is expressed, the large value comes before the small value, and the closed interval is used by default. $ret = $redis- > zRevRangeByScore ('scores', 100,90, [' withscores'= > true]); / / iterate over the elements in the ordered set. / / return value: [element name = > fractional value,..] $ret = $redis- > zscan ('scores', $it,' 10); / / returns the number of elements in the specified ordered set. $ret = $redis- > zCard ('scores'); / / returns the number of members in the specified score range in the ordered set. $ret = $redis- > zCount ('scores', 90,100); / / returns the score value of the specified member in the ordered set. Returns false if the member does not exist. $ret = $redis- > zScore ('scores',' math'); / / returns the ranking of the specified members in the ordered set, sorted by increasing scores. Those with the lowest score rank 0. $ret = $redis- > zRank ('scores',' chemistry'); / / returns the ranking of the specified members in the ordered set, sorted by decreasing scores. The person with the highest score is ranked as 0. $ret = $redis- > zRevRank ('scores',' chemistry'); / / remove one or more members from the ordered set, ignoring members that do not exist. Returns the number of elements deleted. $ret = $redis- > zRem ('scores',' chemistry', 'English'); / / removes all members of the specified ranking interval in the ordered set. $ret = $redis- > zRemRangeByRank ('scores', 0,2); / / removes all members of the specified fractional value range in the ordered set. $ret = $redis- > zRemRangeByScore ('scores', 80,90); / / the score value of a pair of specified members in an ordered set increases the specified increment value. Subtract if the number is negative, create it first if the ordered set does not exist, add it first if there is no corresponding member in the ordered set, and then operate at last. $ret = $redis- > zIncrBy ('scores', 2,' Chinese'); / / calculates the intersection of a given ordered set or sets and stores it in a destination ordered set. The score value of a member in the result set is the sum of the score values of that member in all given sets. $ret = $redis- > zinterstore ('zset3',' zset2', 'zset1'); / / computes the union of a given ordered set or sets and stores it in a destination ordered set. The score value of a member in the result set is the sum of the score values of that member in all given sets. $ret = $redis- > zunionstore ('zset3',' zset2', 'zset1'); thank you for reading! This is the end of this article on "how php implements the Zset operation of Redis". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.