When I run redis-cli script load "$(cat ./scripts/restoreSymbols.lua)"
for the following script:
local list = {}
local result = redis.call('scan', 0, 'MATCH', 'symbol:*', 'COUNT', 1000)
for _, v in ipairs(result[2]) do
list[#list+1] = redis.call('hgetall', v)
end
return list
I get a sha a8a6b471abf42b6cc584444e9d269e9807d96ff1
but when I then run redis-cli --evalsha a8a6b471abf42b6cc584444e9d269e9807d96ff1
I get:
Unrecognized option or bad number of args for: '--evalsha'
How is this possible? I don't need any options or arguments. The script is working (debugged it with the debugger) and also runs when I normal --eval it.
The --evalsha
flag is not a valid redis-cli
option. You can use --eval
to run your script like
redis-cli --eval ./scripts/restoreSymbols.lua
But if you want to use evalsha
to run a loaded script, what you need to do is
redis-cli evalsha a8a6b471abf42b6cc584444e9d269e9807d96ff1 0
Note that you have to pass the 0
to indicate that you are not passing any argument to the command.