tcl - Keep mysql connection open -
i'm making eggdrop tcl script write activity of several public irc channels database (over time 10 15 channels think). have 2 options how handle database connection in mind.
- an user says -> open mysql connection database -> insert information user said -> close connection
- start bot -> open mysql connection database -> insert information when there channel activity -> wait more information etc.
i think it's better use case 1, when there channel activity think opening , closing connection every time cause massive server load , slows things down drastically after while.
what's best way this?
if want keep connection open call
mysql::ping $dbhandle from time time.
this can done this:
proc keepmysqlopen {dbhandle} { mysql::ping $dbhandle after 2000 [list keepmysqlopen $dbhandle] } .... set dbh [mysql::open ...] keepmysqlopen $dbh ... an other option use mysql::ping before accessing db, should according mysqltcl manual reconnect if necessary. might best of both worlds (let connection time out if there not activity, keep open otherwise).
Comments
Post a Comment