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
+13.2k Golang : Convert(cast) int to int64
+7k Web : How to see your website from different countries?
+5.9k AWS S3 : Prevent Hotlinking policy
+10.8k Android Studio : Checkbox for user to select options example
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+6.9k Golang : Decode XML data from RSS feed
+6.8k Golang : Calculate pivot points for a cross
+14.4k Golang : How to filter a map's elements for faster lookup
+7.3k Golang : Of hash table and hash map
+16k Golang : Read large file with bufio.Scanner cause token too long error
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+4.8k Which content-type(MIME type) to use for JSON data