Redis:显示密钥的数据库大小/大小 [英] Redis: Show database size/size for keys

查看:41
本文介绍了Redis:显示密钥的数据库大小/大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 redis 实例似乎变得非常大,我想找出其中的多个数据库中的哪个消耗了多少内存.Redis 的 INFO 命令只是向我显示每个数据库的总大小和键数,这并没有给我太多的洞察力......所以任何工具/想法都可以在监视 redis 服务器时为我提供更多信息将不胜感激.

My redis instance seems to being growing very large and I'd like to find out which of the multiple databases I have in there consumes how much memory. Redis' INFO command just shows me the total size and the number of keys per database which doesn't give me much insight... So any tools/ideas that give me more information when monitoring the redis server would be appreciated.

Redis 文档没有向我展示任何可以返回某些键消耗的内存的命令,所以我想如果有任何错误的代码会向 redis 写入大量垃圾",这可能真的很难找到......

The Redis documentation doesn't show me any commands that can return the consumed memory of certain keys, so I guess if any buggy code would write a lot of "trash" to redis this could be really hard to find...

推荐答案

所以我对自己问题的解决方案:在使用 redis-cli 一段时间后,我发现 DEBUGOBJECT <key> 揭示了类似于 key 的 serializedlength 之类的东西,这实际上是我正在寻找的东西...

So my solution to my own problem: After playing around with redis-cli a bit longer I found out that DEBUG OBJECT <key> reveals something like the serializedlength of key, which was in fact something I was looking for...

对于整个数据库,您需要聚合 KEYS * 的所有值,使用您选择的脚本语言应该不会太困难...

For a whole database you need to aggregate all values for KEYS * which shouldn't be too difficult with a scripting language of your choice...

不好的是redis.io并没有很多关于调试对象.

The bad thing is that redis.io doesn't really have a lot of information about DEBUG OBJECT.

这篇关于Redis:显示密钥的数据库大小/大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆