Skip to content

Instantly share code, notes, and snippets.

@arc279
Last active February 24, 2017 11:10
Show Gist options
  • Save arc279/434abffcdf8bbc57a5c19e13c635f8f0 to your computer and use it in GitHub Desktop.
Save arc279/434abffcdf8bbc57a5c19e13c635f8f0 to your computer and use it in GitHub Desktop.
redisのsetをluaでscan
redis-cli -n 0 --eval test.lua 0 '*' 10
local t_scan = redis.call('SCAN', KEYS[1], 'MATCH', KEYS[2], 'COUNT', KEYS[3])
if next(t_scan[2]) then
local n = {}
for i, v in ipairs(t_scan[2]) do
n[i] = {v, redis.call('SMEMBERS', v) }
end
return {t_scan[1], n}
else
return {t_scan[1], {}}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment