Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis Lua API reference - what is the format of the value returned by redis.call()? #2619

Open
hans-notifi opened this issue Dec 6, 2023 · 0 comments

Comments

@hans-notifi
Copy link

I've written a script to sum over a series of values in Redis:

local sum = 0
local k
local v
for k,v in pairs(KEYS) do
    local counter_value = redis.call('get', v)
    if (counter_value ~= nil) then
        sum = sum + tonumber(counter_value)
    end
end
return sum

When I run the script with my array of keys (which, if they exist, point to numbers created by the INCR command), I get the error user_script:7: attempt to perform arithmetic on a nil value. This tells me that whatever is being returned from redis.call('get', v) isn't just a bare string or number or nil or anything. The documentation doesn't tell us anything either - it just spits the results of redis.call() directly into the script output.

What is the format of the value returned by redis.call()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant