I use a singleton template for mySQL connections in node.js, there is one and only one connection for the entire application to use, I am worried if there is some timeout for this connection contained in singleton.
This connection is expected to work throughout the life of the application. I searched and found persistence examples using the pool, but not sure if this applies to this example, there is no connection pool, there is only one connection that needs to be shared between the components, the question is, is there some kind of timeout, which will remove the connection after it lasts a long time?
puremvc.define( { name: "common.model.connections.App", constructor: function() { var mysql = require("mysql"); this.connection = mysql.createConnection({ host: common.Config.mySQLHost, user: common.Config.mySQLUsername, password: common.Config.mySQLPassword, database: common.Config.mySQLDatabase }); this.connection.connect(); } }, { }, { NAME: "App", instance: null, connection: null, getInstance: function() { if(common.model.connections.App.instance == null) { common.model.connections.App.instance = new common.model.connections.Fico(); } return common.model.connections.App.instance; }, getConnection: function() { return common.model.connections.App.getInstance().connection; } } );
user2727195
source share