#include <cgi/mysqlw.h>
Data Structures | |
| struct | s_conn_pool |
| Connection pool structure. More... | |
Typedefs | |
| typedef struct s_pool_conns | t_pool_conns |
| Connection pool type. | |
Functions | |
| t_conn_pool * | conn_pool_create (long size) |
| Create connection pool. | |
| void | conn_pool_free (t_conn_pool *pool) |
| Free connection pool and release memory. | |
| int | conn_push (t_conn_pool *pool, t_mysql *conn) |
| Push connection to connection pool. | |
| t_mysql * | conn_pop (t_conn_pool *pool) |
| Pop connection from connection pool. | |
Connection pool and related functions. Connection pool is a structure which lets using several prepared MySQL connections in several simultanous sessions without any collision. Using prepared connections drastically speeds up program execution for persistent FastCGI applications.
Typical usage:
On thread startup:
t_mysql *conn = conn_pop(pool); // If there are no connections NULL will be returned. if(!conn) conn = mysqlw_connect(...);
On thread shutdown:
conn_push(pool, conn); // If there is no room for connection, it will be closed.
| typedef struct s_pool_conns t_pool_conns |
Connection pool type.
Connection pool data type. Alias for struct s_conn_pool.
| t_conn_pool* conn_pool_create | ( | long | size | ) |
Create connection pool.
Creates connection pool with specified size.
| size | pool size (in number of connections). |
| void conn_pool_free | ( | t_conn_pool * | pool | ) |
Free connection pool and release memory.
Frees connection pool and releases all memory allocated for it.
| pool | connection pool. |
| t_mysql* conn_pop | ( | t_conn_pool * | pool | ) |
Pop connection from connection pool.
Returns connection from connection pool and removes it from the pool. Returns NULL if there is no more connections.
| pool | connection pool. |
| int conn_push | ( | t_conn_pool * | pool, | |
| t_mysql * | conn | |||
| ) |
Push connection to connection pool.
Pushes connection to connection pool. If there is no room for it, connection will be closed.
| pool | connection pool. | |
| conn | MySQL connection |
1.5.5