else
return 406
end
2) Simplify the logic (note: you never used m3...):
local m1, m2 = redis.call("HMGET", KEYS[1], "mem1", "mem2")
if m1 <= 0 then return 406 end
return (counter > ARGS[1]) and 404 or 200
3) Fix the bugs.
3.a) HMGET returns a table of strings or nil-s, not multiple numbers.
local m = redis.call("HMGET", KEYS[1], "mem1", "mem2")
local m1, m2 = tonumber(m[1] or 0), tonumber(m[2] or 0)
3.b) It is ZINCRBY, not ZINCBY, and I suspect you are not passing the arguments you want. You probably want something like this instead:
redis.call("ZINCRBY", KEYS[1], 1, "mem1")
3.c) You need to convert the argument to a number as well, it is always passed as a string:
return (counter > tonumber(ARGS[1])) and 404 or 200
4) Finally here is the "fixed" script. Of course I cannot fix your logic since I do not know what you are trying to do exactly...
local m = redis.call("HMGET", KEYS[1], "mem1", "mem2")
local m1, m2 = tonumber(m[1] or 0), tonumber(m[2] or 0)
if m1 <= 0 then return 406 end
redis.call("ZINCRBY", KEYS[1], 1, "mem1")
if m2 <= 0 then return 405 end