In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how redis uses scan instructions instead of keys instructions". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how redis uses scan instructions instead of keys instructions".
SCAN cursor [MATCH pattern] [COUNT count]
The SCAN command and its associated SSCAN, HSCAN, and ZSCAN commands are used to incrementally iterate (incrementally iterate) a set of elements (a collection of elements):
The SCAN command iterates over the database keys in the current database.
The SSCAN command is used to iterate over the elements in the collection key.
The HSCAN command is used to iterate over key-value pairs in a hash key.
The ZSCAN command is used to iterate over elements in an ordered collection (including element members and element scores).
The four commands listed above support incremental iterations, and they return only a small number of elements for each execution, so these commands can be used in production environments without the problems caused by KEYS commands and SMEMBERS commands-when the KEYS command is used to process a large database, or when the SMEMBERS command is used to process a large collection key, they can block the server for seconds.
However, the incremental iteration command is not without its drawbacks: for example, using the SMEMBERS command can return all the elements currently contained in the collection key, but for incremental iteration commands such as SCAN, because the key may be modified during the incremental iteration of the key, the incremental iteration command can only provide a limited offer limited guarantees about the returned elements on the returned elements.
Because the SCAN, SSCAN, HSCAN, and ZSCAN commands all work similarly, this document describes all four commands together, but keep in mind:
The first argument to the SSCAN, HSCAN, and ZSCAN commands is always a database key.
The SCAN command does not need to provide any database keys in the first parameter-- because it iterates over all the database keys in the current database.
Scan 0 returns 10 pieces of data by default.
127.0.0.1 scan 6379 > 0
1) "81920"
2) 1) "CMD:1000004739:4"
2) "CMD:1000010475:2"
3) "CMD:380071400001208:766"
4) "CMD:1000006866:LIST"
5) "CMD:380071400001208:20415"
6) "CMD:380071400001231:21530"
7) "CMD:380071400001208:21780"
8) "CMD:7485630165:LIST"
9) "CMD:1000001545:2"
10) "CMD:380071400001231:4387"
You can specify the amount of data to be returned with the count parameter:
127.0.0.1 count 6379 > scan 0
1) "104448"
2) 1) "CMD:1000004739:4"
2) "CMD:1000010475:2"
3) "CMD:380071400001208:766"
4) "CMD:1000006866:LIST"
5) "CMD:380071400001208:20415"
6) "CMD:380071400001231:21530"
7) "CMD:380071400001208:21780"
8) "CMD:7485630165:LIST"
9) "CMD:1000001545:2"
10) "CMD:380071400001231:4387"
.
94) "CMD:201610200062:6"
95) "CMD:VF3748211006:3"
96) "CMD:1000009121:4"
97) "CMD:380071400001231:6563"
98) "CMD:1000010252:ID"
99) "CMD:1000005261:5"
) "SERVER:45568_0"
Use the match parameter to match the pattern:
127.0.0.1 match CMD* count 6379 > scan 0
1) "104448"
2) 1) "CMD:1000004739:4"
2) "CMD:1000010475:2"
3) "CMD:380071400001208:766"
4) "CMD:1000006866:LIST"
5) "CMD:380071400001208:20415"
6) "CMD:380071400001231:21530"
7) "CMD:380071400001208:21780"
8) "CMD:7485630165:LIST"
9) "CMD:1000001545:2"
10) "CMD:380071400001231:4387"
.
86) "CMD:201610200062:6"
87) "CMD:VF3748211006:3"
88) "CMD:1000009121:4"
89) "CMD:380071400001231:6563"
90) "CMD:1000010252:ID"
91) "CMD:1000005261:5"
The most important thing is that scan will not block the server, the existing network environment can also be used, really convenient.
The above is all the contents of the article "how redis uses scan instructions instead of keys instructions". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.