Hello.
I have an application using PHP and MongoDB and wanted to know if there is any way to keep the connection to mongoDB open.
I have the following code that connects to the mongo:
private static function findNome($nome) : String {
$cliente = new \MongoDB\Client("mongodb://192.168.15.100:27017");
$db = $cliente->dbName;
}
Every time I call the findNome()
function, it opens a new connection with the mongo. Can you leave this connection open? need calling only once?
Note: This function is called via ajax using jQuery