Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Usage: redis-cli --eval redis_expire_keys.lua <key-pattern> , <ttl-in-seconds>
- local keys = redis.call("keys", KEYS[1])
- local toExpire = {}
- local i = 1 -- "it is customary in Lua to start arrays with index 1"
- for _, key in ipairs(keys) do
- local val = redis.call('ttl', key)
- if val == -1 then
- toExpire[i] = key
- redis.call('expire', key, ARGV[1])
- i = i + 1
- end
- end
- return toExpire
Add Comment
Please, Sign In to add comment