Reputation: 17900
I am using EVAL
to pass several arguments to my Lua script. However, the last argument is optional, it may or it may be not passed to EVAL
.
How can I check in a Redis Lua script whether an argument is there or not? For example, if ARGV[3]
exists or not.
Upvotes: 1
Views: 1756
Reputation: 67
redis.call('DEL', KEYS[1])
local members = {}
for i = 0, tonumber(ARGV[1]), 1 do
members[i] = ARGV[1+i]
end
redis.call('SADD', KEYS[1], unpack(members))
return 1
Upvotes: 4