Created
April 19, 2014 16:12
-
-
Save itamarhaber/11089063 to your computer and use it in GitHub Desktop.
Kill idle Redis connections
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 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) |
Author
There is a python a script here
https://pranavprakash.net/2016/02/05/kill-idle-connections-to-redis/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, this won't work anymore because
CLIENT KILLisn't allowed from scripts.