redis分好库之后怎么才能看每个库的大小呢?
怪我咯
怪我咯 2017-04-21 11:17:09
0
1
708

我redis里配置了db0、db1、db2、db3四个库,我想看每个库分别占用的大小应该怎么办?
另外jedis里有什么方法可以用吗?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
PHPzhong

Redis does not seem to provide a reliable method to obtain the actual occupation of each db. This is mainly because redis itself does not have the concept of db files, and all dbs are mixed in one rdb file.

To estimate the size of db, you need to pass keys * 遍历 db 里所有的 key,然后用 debug object <key> 来获得 key 的内存占用,serializedlength which is the length of the field occupying memory.

According to the RDB format document, it can be estimated that the actual occupation of each key is:

key_size = strlen(key) + serializedlength + 7

However, this estimate is extremely unreliable, because redis may compress the key, and the estimated value may be too large.


The following command can check the size of db0 (number of keys), and so on for others.

select 0
dbsize

Or use info keyspace to get all db information at the same time.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template