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
| for_real = false | |
| idle_max = 86400 | |
| # redis_constant is a connection pool, the variable c is a single redis client | |
| (clients = redis_constant.with { |c| c.method_missing("client", "list") }.split("\n")).nil? | |
| (addrs = clients. | |
| # select idle clients | |
| select { |client_string| client_string.match(/idle=([\d|\.|:]*)/).captures.first.to_i > idle_max }. | |
| # return ip addresses | |
| map { |client_string| client_string.match(/addr=([\d|\.|:]*)/).captures.first }).nil? |