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