1

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
2
  • 1
    give redis.call('memory',v) a try Commented Apr 2, 2019 at 9:12
  • it says "@user_script:18: ERR Syntax error. Try MEMORY HELP" Commented Apr 3, 2019 at 2:34

1 Answer 1

2

Try this, it worked for me.

redis.call('Memory','Usage', 'key');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.