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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the Redis batch deletion of key and the analysis of setnx usage scenarios, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1. Delete key in batch
To delete the value of a key in redis, you can only delete it by means of del key. What if you want to delete in bulk? Unfortunately, Redis does not support deletion in the regular way of key. So how to achieve this effect? You can use the linux pipe command, as follows:
/ usr/local/redis/bin/redis-cli keys abc:* | xargs / usr/local/redis/bin/redis-cli del
The preceding / usr/local/redis/bin/redis-cli is the client of redis, and keys abc:* means to get all the key that starts with abc:, and then pass these key as parameters (xargs) to the del command behind the pipe. This makes it possible to delete key in batches. But if the prefix of key is followed by a space, then the rule cannot be hit.
Of course, many other parameters can be added after the redis command, such as:
-h ip / / indicates an ip host-p port / / indicates the host port-a password / / indicates the connection password-n 1 / / indicates that the database node with node number 1 is selected (do not write the default connection is 0), and the corresponding command is select 1
such as
/ usr/local/redis/bin/redis-cli-n 1 keys "ab:token*" | xargs / usr/local/redis/bin/redis-cli-n 1 del (integer) 188 / / indicates that 188 key have been deleted
Note that the same parameters are added before and after the pipe, otherwise it will not match.
Of course, if you want to delete all the data from a node, you can directly use the
Flushdbflushall
These two orders.
2, the expiration time of the expire key time_in_seconds command of redis must be an integer, not a decimal. Otherwise, an ERR value is not an integer or out of range error will be reported.
3The setnx usage scene of Magi Redis
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.