You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe I misunderstood something in the code but it seems the shim is managing a connection pool for non-persistent connections. For persistent connections, it relays on the mysqli extension.
Is this to reproduce behavior from the deprecated mysql extension? If not, why is the shim caching non persistent connections? Would it be unadvisable to switch off this behavior?
From the mysqli doc with respect to persistent connections:
The mysqli extension supports persistent database connections, which are a special kind of pooled connections. By default, every database connection opened by a script is either explicitly closed by the user during runtime or released automatically at the end of the script. A persistent connection is not. Instead it is put into a pool for later reuse, if a connection to the same server using the same username, password, socket, port and default database is opened. Reuse saves connection overhead.
In the shim , for non-persistent connections, mysql_connect() is looking up in a pool if the connection already exists using a hash of the connection characteristics. If it exists, it increases a reference counter and returns the existing connection (lines 66-76), thus making a connection pool:
In mysql_close(), the references to the connection are decreased by one and if the connection has zero references, then it is closed. Again, this is managing a connection pool.
Hello,
Maybe I misunderstood something in the code but it seems the shim is managing a connection pool for non-persistent connections. For persistent connections, it relays on the mysqli extension.
Is this to reproduce behavior from the deprecated mysql extension? If not, why is the shim caching non persistent connections? Would it be unadvisable to switch off this behavior?
From the mysqli doc with respect to persistent connections:
In the shim , for non-persistent connections, mysql_connect() is looking up in a pool if the connection already exists using a hash of the connection characteristics. If it exists, it increases a reference counter and returns the existing connection (lines 66-76), thus making a connection pool:
php7-mysql-shim/lib/mysql.php
Lines 66 to 76 in 98f8350
Further down in mysql_connect(), the hash is always associated with the connection:
php7-mysql-shim/lib/mysql.php
Lines 90 to 91 in 98f8350
php7-mysql-shim/lib/mysql.php
Lines 118 to 119 in 98f8350
In mysql_close(), the references to the connection are decreased by one and if the connection has zero references, then it is closed. Again, this is managing a connection pool.
php7-mysql-shim/lib/mysql.php
Lines 153 to 161 in 98f8350
Note that there is a potential error in that code as the there is no check to see if the hash exists. I think it should be factorized as:
Thanks for your consideration.
The text was updated successfully, but these errors were encountered: