In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to use scan in redis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use scan in redis" this article.
When deleting the cache, we need to delete it in batch in some scenarios, but we are not sure the specific key value. We can query it by matching and delete it.
However, using keys can cause the redis server to go down.
Use it cautiously.
In general, companies will also disable more sensitive commands such as keys.
So the scan command is used to match the query at work.
SCAN cursor [MATCH pattern] [COUNT count]
such as
# scan key values that match test1:* from cursor 0, scanning 1000 scan 0 match test1:* count 1000 at a time
1) represents the cursor value for the next scan, and the command line displays a string type. 2) indicates the list of key values matched by this scan
How to implement it with php code, for example
Function getKeysByPattern ($pattern) {$keysList = []; while (true) {/ / @ todo replace the client here with your own redis client object $keys = $client- > scan ($iterator, $pattern,1000); $keysList = array_merge ($keysList, $keys?? []); if ($iterator = 0) {/ / iteration ended and no key break matching pattern was found } if ($iterator = null) {/ / "cursor is null, reset to 0, continue to scan" $iterator = "0";}} $keysList = array_unique ($keysList); return keysList;} above is all the content of the article "how to use scan in redis". 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.