Last active
November 20, 2017 23:32
-
-
Save paulerickson/15c97e2de61e5118b8778ebfcfd24cdd to your computer and use it in GitHub Desktop.
Removes members from set if no corresponding key can be found (assuming "widgets" / "widget:99" naming convention)
This file contains 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
local collectionKey = KEYS[1].."s" | |
local members = redis.call("smembers", collectionKey) | |
for _, id in ipairs(members) do | |
if redis.call("exists", KEYS[1]..":"..id) == 0 then | |
redis.call("srem", collectionKey, id) | |
end | |
end | |
return redis.call("scard", collectionKey) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment