Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Connection Pools

Comments in 'Plugin Development' started by Brutus, Sep 3, 2015.

  1. Brutus
    Offline

    Brutus New Member

    Joined:
    Aug 31, 2015
    Posts:
    21
    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.
  2. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    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.
  3. Brutus
    Offline

    Brutus New Member

    Joined:
    Aug 31, 2015
    Posts:
    21
    That is not quite what a connection pool is, but thank you for that insight.

    That lacks:
    1. Multiple concurrent connections in the pool.
    2. Easy access to connections for multiple modules that may be running concurrently and have no knowledge of each other.
    3. The ability for the connection pool to create connections as needed and let them timeout when they are disused.
    4. Automated connection maintenance over time to prevent timeouts when that is desired.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    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.
    Brutus likes this.

Share This Page

Advertisement