Redi Sorder Set structure and command detailed

Source: Internet
Author: User

Zadd key Score1 value1 score2 value2. add element Redis 127.0.0.1:6379> zadd stu Lily Lilei lilei (integer) 3zrem key value1 value2. Action: Removes elements from the collection Zremrangebyscore key min Max effect: Delete elements by socre, remove score redis 127.0.0.1:6379> between [Min,max] Zremrangebyscore Stu 4 (integer) 2redis 127.0.0.1:6379> zrange stu 0-11) "F" zremrangebyrank key start end effect: Delete elements by rank  , delete the position between [Start,end] Redis 127.0.0.1:6379> zremrangebyrank stu 0 1 (integer) 2redis 127.0.0.1:6379> zrange Stu 0-11) "C" 2) "E" 3) "F" 4) "G" Zrank key member query member ranking (up to 0 start) Zrevrank key memeber query member ranking (down 0 start) zrange key start Stop [ Withscores] After sorting the set, return to the position [start,stop] of the element by default is the ascending sequence withscores is the score also print out Zrevrange key start Stop function: Set descending order, take the name [start,  Stop] element zrangebyscore key min Max [withscores] limit offset n function: Set (ascending continuation) after sorting, take score element within [Min,max] and Skip offset, remove n redis  127.0.0.1:6379> zadd Stu 1 a 3 B 4 C 9 E F g (integer) 6redis 127.0.0.1:6379> zrangebyscore stu 3 limit 1 2 WITHSCORES1) "C" 2) "4" 3) "E" 4)"9" Zcard key returns the number of elements zcount key min Max returns the amount of elements in the [Min,max] interval zinterstore destination Numkeys key1 [Key2 ...] [WEIGHTS weight [weight ...] [AGGREGATE sum| min| MAX] asks for the intersection of Key1,key2, the weights of Key1,key2 are weight1,weight2 aggregation methods: Sum |min|max aggregation results, saved in Dest collection note: Weights, aggregate How to understand? A: If there is a intersection, the intersection element has socre,score how to deal with it? Aggregate sum->score Add, min to minimum score, Max score another: You can set the weight of different keys by Weigth, when the intersection, Socre * weights See the following example Redis 127.0.0.1:637 9> Zadd Z1 2 a 3 B 4 C (integer) 3redis 127.0.0.1:6379> zadd Z2 2.5 a 1 B 8 d (integer) 3redis 127.0.0.1:6379> zint  Erstore tmp 2 Z1 z2 (integer) 2redis 127.0.0.1:6379> zrange tmp 0-11) "B" 2) "a" Redis 127.0.0.1:6379> zrange tmp 0-1 WITHSCORES1) "B" 2) "4" 3) "a" 4) "4.5" Redis 127.0.0.1:6379> zinterstore tmp 2 z1 z2 aggregate sum (integer) 2redis 127.0. 0.1:6379> zrange tmp 0-1 withscores1) "B" 2) "4" 3) "a" 4) "4.5" Redis 127.0.0.1:6379> zinterstore tmp 2 Z1 Z2 Aggregat E min (integer) 2redis 127.0.0.1:6379> zrange tmp 0-1 withscores1) "B" 2) "1" 3) "a" 4) "2" ReDis 127.0.0.1:6379> zinterstore tmp 2 z1 Z2 weights 1 2 (integer) 2redis 127.0.0.1:6379> zrange tmp 0-1 withscores1) "B" 2) "5" 3) "a" 4 "7"

07-order set structure and command explanation

Redi Sorder Set structure and command detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.