Disclaimer: I am mostly new to php and pocketmine. I am wondering if anyone knows of a way to do SQL connection pooling in a php PocketMine plugin. An example of someone doing it would be very welcome as well. Connection pooling is so useful and efficient compared to the performance I am getting creating connections for each task. Thank you very much.
You are thinking about PHP web programming. In PocketMine you simply make your connection in onEnable and save it as a member variable of your plugin class. Suggest you look into SimpleAuth source to see a good example on how to keep a MySQL connection around.
That is not quite what a connection pool is, but thank you for that insight. That lacks: Multiple concurrent connections in the pool. Easy access to connections for multiple modules that may be running concurrently and have no knowledge of each other. The ability for the connection pool to create connections as needed and let them timeout when they are disused. Automated connection maintenance over time to prevent timeouts when that is desired.
Is this something you want to look for? https://github.com/LegionPE/LegionPE-Theta-Base/blob/master/src/legionpe/theta/query/AsyncQuery.php Also, I would like to remind you that PocketMine does everything in the main thread, so you only want to do concurrent tasks when you are in an AsyncTask.