You can't cast a table to a number in lua. What you want is to grab the number of elements in the table instead. You can do this by using the last element point #
. Also, I'd highly recommend separating out your Lua script from the rest of your code, so it's cleaner. Your Lua script should look like:
local first_key = redis.call('get',KEYS[1])
local second_key = redis.call('get',KEYS[2])
return #first_key * #second_key
EDIT: Misunderstood the question. OP correctly pointed out he is trying to multiple two numbers stored as strings rather than a table length. In that case:
local first_key = redis.call('get',KEYS[1])
if not tonumber(first_key) then return "bad type on key[1]" end
local second_key = redis.call('get',KEYS[2])
if not tonumber(second_key) then return "bad type on key[2]" end
return tonumber(first_key) * tonumber(second_key)