Golang database/sql.DB.SetMaxIdleConns function example
package database/sql
SetMaxIdleConns sets the maximum number of connections in the idle connection pool.
If MaxOpenConns is greater than 0 but less than the new MaxIdleConns then the new MaxIdleConns will be reduced to match the MaxOpenConns limit
If n <= 0, no idle connections are retained.
Golang database/sql.DB.SetMaxIdleConns function usage example
const concurrencyLevel = 10
db := initDB(b,
"DROP TABLE IF EXISTS foo",
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
`INSERT INTO foo VALUES (1, "one")`,
`INSERT INTO foo VALUES (2, "two")`,
)
db.SetMaxIdleConns(concurrencyLevel) // <-- here
defer db.Close()
Reference :
Advertisement
Something interesting
Tutorials
+15k Golang : package is not in GOROOT during compilation
+10.6k Golang : Get local time and equivalent time in different time zone
+7.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+7.1k Nginx : How to block user agent ?
+29.5k Golang : Login(Authenticate) with Facebook example
+23.2k Golang : Print out struct values in string format
+17.9k Golang : Simple client server example
+5k Golang : micron to centimeter example
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+7.9k Javascript : Put image into Chrome browser's console
+11.3k Golang : Intercept and process UNIX signals example