I am using a lua script to implement a difference function. The specific lua code is as follows. After I execute it with spring boot, I will receive a "MOVED prompt". I don't quite understand why there is this prompt. I just created a temporary key and then used it as sdiff My environment is cluster mode
lua
local key = KEYS[1]
local keyTmp = KEYS[2]
local values = ARGV[1]
local valuesArray = {}
for value in values:gmatch("[^,]+") do
table.insert(valuesArray, value)
end
local ok, result = pcall(function()
redis.call('SADD', keyTmp, unpack(valuesArray))
local res = redis.call('SDIFF', keyTmp, key)
redis.call('DEL', keyTmp)
return {200, "success", res}
end)
if not ok then
return {401, result,{}}
end
return result
Comment From: sundb
you should make sure that KEY[1] and KEY[2] are all belong to the current cluster node, otherwise it will return the MOVE prompt.