In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to check the use of Redis Key resources, I hope you have something to gain after reading this article, let's discuss it together!
In daily development, Redis accumulates a lot of Key and takes up a lot of memory space. Sometimes we want to know how many Key there are in the current Redis and which Key takes up the most memory.
However, we know that because Redis is a single-threaded database, the online environment absolutely forbids the use of the keys * command, because it takes a long time to scan all Key, and in the process, the Redis will get stuck and cannot handle other read and write operations.
So, how do we know how many Key are currently available? Some students said that you can use the scan command. But on the one hand, this command needs to write a program to iterate, on the other hand, the results it gives may be inaccurate.
Some students will also say that you can use the info keyspace command, and the running effect is as follows:
You can really see how many Key there are. But the other question is, how do you know which Key takes up the most memory space?
Sometimes, there may be tens of thousands of Key in Redis, some of which can be deleted. But since we can't use the keys command to see which Key are currently available, we don't know that the Key that can be deleted is still there.
In fact, these problems can be solved by using a tool called RDR [1]. On RDR's Github, you can find the executable file for the corresponding system. Let's take the Linux version as an example. The executable file address of the Linux version is: https://github.com/xueqiu/rdr/releases/download/v0.0.1/rdr-linux. After downloading, grant the executable permission:
Cd ~ wget https://github.com/xueqiu/rdr/releases/download/v0.0.1/rdr-linux chmod + x rdr-linux
Next, we need to find the dump.rdb file.
Redis enables persistent storage in RDB mode by default. When certain conditions are met, Redis will store the data in memory on the hard disk to prevent data loss due to a sudden power outage. By default, the RDB file is in / var/lib/redis/dump.rdb, which can only be read by root users.
If you are not a root user, you can copy it out and modify it to the current user. The current user of my Linux system is called kingname, and the user group is also called kingname, so you can execute the following shell command:
Cd ~ sudo cp / var/lib/redis/dump.rdb. / sudo chown kingname:kinganme dump.rdb
After modifying the user, we now have RDR read the RDB file:
. / rdr-linux show-p 8766 dump.rdb
The running effect is shown in the following figure:
Now, open the browser and http://IP:8766, and you can see the statistics of each Key of the current Redis:
After reading this article, I believe you have a certain understanding of "how to check Redis Key resource usage". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.