Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取nodejs mysql连接池中未使用/已使用的连接数?_Mysql_Node.js_Connection Pooling - Fatal编程技术网

如何获取nodejs mysql连接池中未使用/已使用的连接数?

如何获取nodejs mysql连接池中未使用/已使用的连接数?,mysql,node.js,connection-pooling,Mysql,Node.js,Connection Pooling,我正在使用nodejs连接池和npm的“mysql”模块。 创建池时,我已将connectionLimit指定为100。 我想知道在运行时池中使用/未使用了多少连接。通过查看,您可以查看: pool.config.connectionLimit // passed in max size of the pool pool._freeConnections.length // number of free connections awaiting use pool._allConne

我正在使用nodejs连接池和npm的“mysql”模块。 创建池时,我已将connectionLimit指定为100。 我想知道在运行时池中使用/未使用了多少连接。

通过查看,您可以查看:

pool.config.connectionLimit     // passed in max size of the pool
pool._freeConnections.length    // number of free connections awaiting use
pool._allConnections.length     // number of connections currently created, including ones in use
pool._acquiringConnections.length // number of connections in the process of being acquired
注意:将根据需要创建新连接,直到池的最大大小,因此
\u freeConnections.length
可以为零,但限制中还有更多连接,因此下次调用
.getConnection()
时,它将创建新连接