In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Welcome to join the 459479177QQ group to communicate.
This chapter is the last of the five ways of ordered collection of Redis Sorted Set.
First we use redis-cli to enter the redis
[root@web1 ~] # redis-cli 127.0.0.1 purl 6379 >
1 > zadd
Method: zadd key source1 [key sourceN...]
Description: add one or more ordered collection member elements, update the member's score value if it exists, and insert this idiom to ensure that the member is in the correct location, create a new key if the key does not exist, and then perform the zadd operation
127.0.0.1 zadd zkey1 1 Sunshine\\ first member score 1 (integer) 1127.0.0.1 withscores1 6379 > zrange zkey1 0-1 withscores1) "Sunshine" 2) "1" 127.0.1 withscores1 6379 > integer 3 Sunshine\\ member score 3 (integer) 0127.0.0.1 withscores 6379 > zrange zkey1 0-1 withscores\\ member score becomes 3 Member elements unchanged 1) "Sunshine" 2) "3"
2 > zcard
Method: zcard key
Description: check the number of member elements of key. A score corresponds to multiple elements.
127.0.0.1 Sunshine2 1 Sunshine3 (integer) 3127.0.1 Sunshine2 6379 > zcount zkey 1 3 (integer) 3127.0.1 Sunshine2 6379 > zrange zkey 0-1 withscores1) "Sunshine" 2) "1" 3) "Sunshine2" 4) "1" 5) "Sunshine3" 6) "1"
3 > zcount
Method: zacount key min max
Description: statistics of the member elements of the specified collection
127.0.0.1 zrange zkey2 0-1 withscores (empty list or set) 127.0.0.1 zrange zkey2 6379 > zadd zkey2 1 Sushine 1 Sunshine0 (integer) 2127.0.0.1 Sushine 6379 > zrange zkey2 0-1 withscores1) "Sunshine0" 2) "1" 3) "Sushine" 4) "1" 127.0.0.1L zcount zkey2 6379 > zcount zkey2 12 (integer) 2
4 > zincrby
Method: zincrby key increment member
Description: specifies the increment of the member score value for the ordered collection, or minus if-
127.0.0.1Sunshine0 6379 > zrange zkey2 0-1 withscores1) "Sunshine0" 2) "1" 3) "Sushine" 4) "1" 5) "Sunshine" 6) "5" 127.0.0.1 Sunshine "6)" 5 "127.0.0.1 Sunshine"10" 127.0.0.1Sunshine "10" 127.0.0.1 > Sunshine 0-1 withscores1) "Sunshine0" 2) "1" 3) "Sushine" 4) "1" 5) "Sunshine" 6) "10" 127. 0.0.1 Sunshine0 6379 > zincrby zkey2-5 "Sunshine"5" 127.0.0.1 withscores1) "Sunshine0" 2) "1" 3) "Sushine" 4) "1" 5) "Sunshine" 6) "5"
5 > zintersotre
Method: zintersotre destination numkeys key [key...] [weights weighe [weight...]] [aggregate sun | min | max]
Description: add the same member score values of the collection after the destination and add to the destinatio collection member
127.0.0.1 withscores1) "Sunshine" 2) "11" 3) "SunshineBoy" 4) "44" 127.0.0.1 zrange zkey4 0-1 withscores1) "Sunshine" 2) "22" 3) "SunshineBoy" 4) "33" 127.0.1 zkey4 zkey3 (integer) 2127.0.1 zrange zkey5 0-1 withscores1) "Sunshine" 2) "33" 3) "SunshineBoy" 4) "77"
6 > zlexcount
Method: zlexcount key min max
Description: specifies the number of interval members of the ordered set dictionary
127.0.0.1 zrange zkey6 0-1 withscores 1) "a" 2) "0" 3) "b" 4) "0" 5) "c" 6) "0" 7) "d" 8) "0" 9) "e" 10) "0" 11) "f" 12) "0" 13) "g" 14) "0" 127.0.1 zlexcount zkey6 .0.1 6379 > zlexcount zkey6 [b [g (integer) 6]
7 > zrange
Method: zrange key start end [withscores]
Description: specify to view ordered set interval members
127.0.0.1 zrange zkey6 0-1 withscores1) "a" 2) "0" 3) "b" 4) "0" 5) "c" 6) "0" 7) "d" 8) "0" 9) "e" 10) "0" 11) "f" 12) "0" 13) "g" 14) "0" 127.0.1 withscores1) "a" 2) "0" 3) "b" 4) "0" 5) "c" 6) "0" 7) "d" 8) "0"
8 > zrangebylex
Method: zrangebylex key min max [limit offset count]
Description: returns ordered set members through a dictionary interval
127.0.0.1 zrangebylex zkey6-[C1) "a" 2) "b" 3) "c" 127.0.0.1 "zrangebylex zkey6-+ 1)" a "2)" b "3)" c "4)" d "5)" e "6)" f "7)" g "127.0.0.1 6379 > zrange zkey6 0-1 withscores 1)" a "2)" 0 "3)" b "4 ) "0" 5) "c" 6) "0" 7) "d" 8) "0" 9) "e" 10) "0" 11) "f" 12) "0" 13) "g" 14) "0"
9 > zrangesotre
Method: zrangesotre key min max [withscores] [limit offsec count]
Description: returns interval members by member score values
127.0.0.1 jack 6379 > zrangebyscore zkey10-inf + inf\\ displays the whole ordered set member 1) "jack" 2) "tom" 3) "Sunshine" 127.0.0.1 jack 6379 > zrangebyscore zkey10-inf + inf withscores\\ displays the score1 of the entire ordered set member) "jack" 2) "2000" 3) "tom" 4) "8000" 5) "Sunshine" 6) "15000" 127.0. 0.1 jack 6379 > zrangebyscore zkey10-inf 5000 withscores\\ displays members less than or equal to 5000 points 1) "jack" 2) "2000" 127.0.0.1 withscores 6379 > zrangebyscore zkey10 (5000 20000 withscores\\ displays members between 5000 and 20000) "tom" 2) "8000" 3) "Sunshine" 4) "15000" 127.0.0.1 Suzhou 6379 >
10 > zrank
Method: zrank key member
Description: displays the index (index or subscript) of the members of an ordered collection
127.0.0.1 zrank zkey10 tom (integer) 1127.0.0.1 zrank zkey10 Sunshine (integer) 2127.0.0.1 > zrank zkey10 jack (integer) 0127.0.0.1 > zrange zkey10 0-1 withscores1) "jack" 2) "2000" 3) "tom" 4) "8000" 5) "Sunshine" 6) "15000"
11 > zrem
Method: zrem key member [member...]
Description: remove an ordered collection member or multiple
127.0.0.1 zrange zkey10 0-1 withscores1) "jack" 2) "2000" 3) "tom" 4) "8000" 5) "Sunshine" 6) "15000" 127.0.1 tom 6379 > zrem zkey10 jack (integer) 1127.0.1 withscores 6379 > zrem zkey10 tom Sunshine (integer) 2127.0.1 0.1 withscores > empty list or set)
12 > zremrangebylex
Method: zremrangebylex key min max
Description: the Zremrangebylex command is used to remove all members of a given dictionary interval in an ordered set
127.0.0.1 zrange zkey2 0-1 withscores 1) "a" 2) "1" 3) "b" 4) "1" 5) "c" 6) "1" 7) "d" 8) "1" 9) "e" 10) "1" 11) "f" 12) "1" 13) "g" 14) "1" 15) "h" 16) "1" 17) "l" 18) "1" 19) "m" 20) "1" 127.0.0.1 zrange zkey2 6379 > zremrangebylex zkey2 [a [c (integer) 3127.0.0.1 zrange zkey2 0-1 withscores 1) "d" 2) "1" 3) "e" 4) "1" 5) "f" 6) "1" 7) "g" 8) "1" 9) "h" 10) "1" 11) "l" 12) "1" 13) "m" 14) "1" 127.0.0.1 zrange zkey2 6379 > zremrangebylex zkey2 [d [h (integer) 5127.0.1 zrange zkey2 0-1 withscores1) "l" 2) "1" 3) "m" 4) "1"
13 > zremrangeburank
Method: zremrangebyrank key start end
Description: removes all members of a given ranking range in an ordered set (specified refers to a subscript)
127.0.0.1 zrange zkey11 0-1 withscores1) "Sunshine" 2) "100" 3) "SunshineBoy" 4) "200" 5) "SnshineBoySZF" 6) "300" 127.0.1 SunshineBoy 6379 > zremrangebyrank zkey11 00 (integer) 1127.0.1 zremrangebyrank zkey11 0-1 withscores1) "SunshineBoy" 2) "200" 3) "SnshineBoySZF" 4) "300" 127.0.1 1 zremrangebyrank zkey11 6379 > zremrangebyrank zkey11 00 (integer) 1127.0.0.1 withscores1 6379 > zrange zkey11 0-1 withscores1) "SnshineBoySZF" 2) "300" 127.0.0.1 hehe (integer) 1127.0.0.1 hehe 6379 > zrange zkey11 0-1 withscores1) "SnshineBoySZF" 2) "300" 3) "hehe" 4) "500" 127.0.1) zremrangebyrank zkey11 01 (integer) 2127.0.1 withscores 6379 > zrange zkey11 0-1 withscores (empty list or set)
14 > zremrangebyscore
Method: zremrangebyscore key min max
Description: specify an ordered set and remove (score) members of the interval
127.0.0.1 SunshineBoy 6379 > zadd zkey12 100 Sunshine 200 SunshineBoy 300 SnshineBoySZF (integer) 3127.0.1 SunshineBoy 6379 > zrange zkey12 0-1 withscores1) "Sunshine" 2) "100" 3) "SunshineBoy" 4) "200" 5) "SnshineBoySZF" 6) "300" 127.0.1 zremrangebyscore zkey12 300 (integer) 2127.0.1) zrange zkey12 0-1 withscores1) "Sunshine" 2)
15 > zrevrage
Method: zrevrange key start end [withscores]
Description: specifies the reverse order of ordered collections
127.0.0.1 zrange zkey12 0-1 withscores1) "Sunshine" 2) "100" 3) "SunshineBoy" 4) "200" 5) "SnshineBoySZF" 6) "300" 127.0.1) SnshineBoySZF "6)" SnshineBoySZF "2)" 300 "3)" SunshineBoy "4)" 200 "5)" Sunshine "6)" 100"
16 > zrevrangebybscore
Method: zrevrangebyscore key min max [withscores] [limit offsec count]
Description: specify an ordered set, sort from top to bottom according to the specified score value (that is, in reverse order according to the specified value)
127.0.0.1 6379 > zrevrange zkey12 0-1 withscores
1) "SnshineBoySZF"
2) "300"
3) "SunshineBoy"
4) "200"
5) "Sunshine"
6) "100"
127.0.1 inf 6379 > zrevrangebyscore zkey12 + reverse-inf\\
1) "SnshineBoySZF"
2) "SunshineBoy"
3) "Sunshine"
127.0.0.1 zrevrangebyscore zkey12 6379 > 200100
1) "SunshineBoy"
2) "Sunshine"
17 > zrevrank
Method: zrevrank key start end [withscores] [limit offsec count]
127.0.0.1 zrange zkey 0-1 withscores1) "sunshine" 2) "100" 3) "tom" 4) "200" 5) "jack" 6) "500" 7) "hehe" 8) "2000" 127.0.0.1 jack 6379 > zrevrank zkey tom (integer) 2127.0.0.1 > zrevrank zkey hehe (integer) 0
18 > zscore
Method: zscore key member
Description: returns the score value of a member in an ordered collection
127.0.0.1 zrange zkey 0-1 withscores1) "sunshine" 2) "100" 3) "tom" 4) "200" 5) "jack" 6) "500" 7) "hehe" 8) "2000" 127.0.0.1 jack 6379 > zscore zkey tom "200" 127.0.1 jack 6379 > zscore zkey jack "500"
19 > zunionstore
Methods: ZUNIONSTORE destination numkeys key [key...] [WEIGHTS weight [weight...]] [AGGREGATE SUM | MIN | MAX] {directly copy the official, the official example is not clear, allow later rewriting refers to the theory}
Description: calculates the union of a given ordered set or sets and stores it in a new key.
127.0.0.1 zadd zkey1 200b (integer) 2127.0.0.1 zadd zkey2 6379 > zadd zkey2 300 c 400b 500 e (integer) 1127.0.0.1 zunionstore zkey3 2 zkey1 zkey2 (integer) 4127.0.1zunionstore zkey3 0-1 withscores1) "a" 2) "100" 3) "c" 4) "300" 5) "e" 6) "500" 7) "b" 8) "600"
20 > zscan
Method: ZSCAN key cursor [MATCH pattern] [COUNT count]
Description: elements in an iterative ordered collection (including element members and element scores)
127.0.0.1 zrange zkey 0-1 withscores 1) "No_s\ x94ql" 2) "1" 3) "abc" 4) "1" 5) "ao" 6) "1" 7) "apche" 8) "1" 9) "mysql" 10) "1" 11) "nginx" 12) "1" 127.0.0.1 1 match a * count 11) "0" 2) 1) abc " "2)" 1 "3)" ao "4)" 1 "5)" apche "6)" 1 "
At this point, the orderly collection of Redis sorted set is over!
Welcome to join the 459479177QQ group to communicate.
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.