Skip to content

Instantly share code, notes, and snippets.

@kougazhang
Created July 1, 2021 13:32
Show Gist options
  • Save kougazhang/3964a163a649da7f8aa770eae0971c6d to your computer and use it in GitHub Desktop.
Save kougazhang/3964a163a649da7f8aa770eae0971c6d to your computer and use it in GitHub Desktop.
redis 执行 lua 脚本 #redis #lua
-- 返回 set 中非 download 状态的成员。
local setName = KEYS[1]
local val = redis.call("sscan", setName, KEYS[2])
-- set 为空
if (val[1] == "0") then
return {}
end
local res = {}
-- val[2] 是数组
for i, v in ipairs(val[2]) do
local got = redis.call("get", v)
if (got ~= "download") then
table.insert(res, v)
end
end
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment