I am getting an error message when running this command:
redis-cli --eval myscript.lua myzset 3 "one"
Error message:
(error) ERR Error running script (call to f_9c623c243d74e75a4fe64de7a6826b47f8d7
d400): @user_script:1: @user_script: 1: Lua redis() command arguments must be st
rings or integers
Lua script:
local ans = redis.call('ZINCRBY', KEYS[1], ARGV[1], ARGV[2])
if tonumber(ans) <= 0 then
redis.call('ZREM', KEYS[1], ARGV[2])
end
return (tonumber(ans) < 1 and '-1' or ans)
The goal is to remove automatically Zero or Negative value using ZINCRBY
.
I am using:
Windows 7 64bit Redis Version: 3.2.100
Your help will be appreciated.