0

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.

Cliff Anger
  • 195
  • 2
  • 11

1 Answers1

0

The problem you're experiencing due to the fact that you're not separating the KEYS and ARGS - use a comma in the command line to do so. Also, note that since the comma is the delimiter, you'll need to use an extra space in order to ensure that it isn't regarded as a part of the key.

Like so:

redis-cli --eval myscript.lua myzset , 3 "one"
Itamar Haber
  • 47,336
  • 7
  • 91
  • 117