Created
July 1, 2021 13:32
-
-
Save kougazhang/3964a163a649da7f8aa770eae0971c6d to your computer and use it in GitHub Desktop.
redis 执行 lua 脚本 #redis #lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 返回 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