Skip to content

Instantly share code, notes, and snippets.

@Checksum
Created March 23, 2022 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Checksum/60ae7e0e088733a8b33aaf97cf234f68 to your computer and use it in GitHub Desktop.
Save Checksum/60ae7e0e088733a8b33aaf97cf234f68 to your computer and use it in GitHub Desktop.
Redis Lua helpers
local function key_patterns()
local uniq = {}
for _, key in ipairs(redis.call('keys', '*')) do
local pattern = string.match(key, "(.-):")
if pattern ~= nil and pattern ~= "" then
if uniq[pattern] == nil then
table.insert(uniq, pattern)
uniq[pattern]=1
else
uniq[pattern]=uniq[pattern]+1
end
end
end
return uniq
end
if ARGV[1] == nil or ARGV[1] == "" then
return key_patterns()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment