Disconnect all connections
that have been idle for at least minimum_idle seconds. Connections
currently checked out, or that were checked in less than
minimum_idle seconds ago, are unaffected.
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 435
def flush(minimum_idle = @idle_timeout)
return if minimum_idle.nil?
idle_connections = synchronize do
return if self.discarded?
@connections.select do |conn|
!conn.in_use? && conn.seconds_idle >= minimum_idle
end.each do |conn|
conn.lease
@available.delete conn
@connections.delete conn
end
end
idle_connections.each do |conn|
conn.disconnect!
end
end