Skip to content

Instantly share code, notes, and snippets.

@itamarhaber
Created April 19, 2014 16:12
Show Gist options
  • Save itamarhaber/11089063 to your computer and use it in GitHub Desktop.
Save itamarhaber/11089063 to your computer and use it in GitHub Desktop.
Kill idle Redis connections
local l = redis.call('client', 'list')
local k = 0
for r in l:gmatch('[^\n]+') do
for c,i in r:gmatch('addr=(.+:%d+).*idle=(%d+).*') do
if tonumber(i) > tonumber(ARGV[1]) then
redis.call('client', 'kill', c)
k = k + 1
end
end
end
return(k)
@macedd
Copy link

macedd commented Mar 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment