Reuse MySQL connections within requests

This commit is contained in:
root
2026-07-13 00:08:07 +00:00
parent 0ff42f357f
commit b1dfe6c807
5 changed files with 73 additions and 21 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ Establishes a connection to a MySQL server and returns a pointer to the connecti
This connection handle is then used with helpers such as `mysql_query()`, `mysql_error()`, and `mysql_disconnect()`.
MySQL handles are request-scoped framework resources. If a request exits without calling `mysql_disconnect()`, UCE closes any remaining MySQL handles during request cleanup. Call `mysql_disconnect()` when you want to close early, but never store a `MySQL*` in globals, sessions, or other state that can outlive the current request.
MySQL handles are request-scoped framework resources. Repeated `mysql_connect()` calls with the same host and credentials reuse one server connection within the current request. Each call creates a lease; `mysql_disconnect()` releases that lease, and UCE closes the pooled server connection during request cleanup. Never store a `MySQL*` in globals, sessions, or other state that can outlive the current request.
:example
MySQL* db = mysql_connect();
+1 -1
View File
@@ -10,7 +10,7 @@ m : pointer to an existing MySQL connection struct
:content
Closes an existing connection to a MySQL server.
Call this when you want to release a `MySQL*` connection handle before the request ends. UCE also closes any remaining MySQL handles automatically during request cleanup, including handles skipped by exceptions or fatal request recovery. A `MySQL*` is only valid inside the request that opened it; do not cache it across requests.
Releases the lease returned by `mysql_connect()`. The request-local server connection remains available for another same-credential `mysql_connect()` call and is closed by UCE during request cleanup, including after exceptions or fatal request recovery. A `MySQL*` is only valid inside the request that opened it; do not use it after release or cache it across requests.
:example
MySQL* db = mysql_connect();