Peter Berg
Peter Berg

Reputation: 6206

How can I determine the amount of memory the value for a given key takes up on Redis?

From what I understand after looking at the redis docs, you can (essentially) determine the memory used by a string using STRLEN, but what if I want to determine the amount of memory used by a list or a hash?

Ideally I'd like to be able to to do this without using a plugin or third party software. Perhaps I need to EVAL a lua script?

Upvotes: 0

Views: 44

Answers (2)

abhi
abhi

Reputation: 1084

Dont know about Lua Script, But here is a small .net application which can help you determine the size used by each key in your redis database,

You can use .net application https://github.com/abhiyx/RedisSizeCalculator to calculate the size of redis key,

Upvotes: 1

Itamar Haber
Itamar Haber

Reputation: 49942

At the moment (v3.2.1) Redis doesn't provide this kind of introspective functionality, and I'm afraid that a Lua script would be of little use in this case.

However, there exists a pull request by my colleague that adds this - https://github.com/antirez/redis/pull/3223 - and I expect it'll be merged eventually.

Upvotes: 1

Related Questions