Guest User

Untitled

a guest
Feb 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. -- Usage: redis-cli --eval redis_expire_keys.lua <key-pattern> , <ttl-in-seconds>
  2. local keys = redis.call("keys", KEYS[1])
  3. local toExpire = {}
  4. local i = 1 -- "it is customary in Lua to start arrays with index 1"
  5. for _, key in ipairs(keys) do
  6. local val = redis.call('ttl', key)
  7. if val == -1 then
  8. toExpire[i] = key
  9. redis.call('expire', key, ARGV[1])
  10. i = i + 1
  11. end
  12. end
  13. return toExpire
Add Comment
Please, Sign In to add comment