Created
March 23, 2022 03:59
-
-
Save Checksum/60ae7e0e088733a8b33aaf97cf234f68 to your computer and use it in GitHub Desktop.
Redis Lua helpers
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
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