Created
January 11, 2025 03:16
-
-
Save nicksherron/ba642d5b9a2144cf66ff329b74fd1cd4 to your computer and use it in GitHub Desktop.
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
-- Desc: This script will return all keys that do not have a TTL set. | |
-- Usage: redis-cli --eval nottlkeys.lua | |
local nonttl = {} | |
local cursor = "0" | |
local done = false | |
while not done do | |
repeat | |
local result = redis.call("SCAN", cursor, "MATCH", "*", "COUNT", 1000) | |
cursor = result[1] | |
local scanned = result[2] | |
for i, key in ipairs(scanned) do | |
local ttl = redis.call("TTL", key) | |
if ttl == -1 then | |
table.insert(nonttl, key) | |
end | |
end | |
if cursor == "0" then | |
done = true | |
end | |
until done | |
end | |
return nonttl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment