My redis keys are ordered using all kind of topics (e.g. Topic:SubTopic:Key).
I would like to find the byte size of a section Topic:* or a Topic:SubTopic:*.
Beneath a topic I can have all kinds of entries (lists, strings, hashes, sets etc.).
Now I know the cli has the memory usage <key> command, but I'd like to somehow call this on the redis server using lua.
My approach was to run something like:
eval "local keys = redis.call('keys',KEYS[1]) ; local sum=0 ; for _,k in ipairs(keys) do sum = sum + redis.call('memory usage', k) end ; return sum" 1 Topic:SubTopic:*
I know that this command has a performance impact, and therefore I'm going to run this offline just to analyze our data structures and not on production.
My main problem is that I couldn't find a redis server command to find the memory usage of a key that is similar to the cli command.
Questions:
Is there a better approach to analyze my keys? Using
bigkeysisn't enough.If not, is there any equivalent memory usage command that I can run as part of a lua script to get the byte size of a key?