1
votes

I want to count key's memory consumption with the following code, but get the error

@user_script:22: @user_script: 22: Unknown Redis command called from Lua script

. I can call the command "MEMORY USAGE" in the command line. Why in the Lua script?

for i,v in ipairs(match) do
     local val = redis.call('TYPE',v)
     if val.ok == 'list' then
         local llength = redis.call('LLEN',v)
         if llength> ll.max then
               ll.max = llength
               ll.key = v
         end
         local lbyte = redis.call('MEMORY USAGE',v)
         if lbyte > lb.bytes then
               lb.max = lbyte
               lb.key = v
         end
     end
     detail[val.ok] = detail[val.ok] +1
end
127.0.0.1:6379[27]> MEMORY USAGE ants_monitor_invoke_list_date_2016-01-09
(integer) 105588597
1
give redis.call('memory',v) a try - Piglet
it says "@user_script:18: ERR Syntax error. Try MEMORY HELP" - user1208081

1 Answers

1
votes

Try this, it worked for me.

redis.call('Memory','Usage', 'key');