MySQLPool

A lightweight convenience interface to a MySQL/MariaDB database using vibe.d's ConnectionPool.

You have to include vibe.d in your project to be able to use this class. If you don't want to, refer to mysql.connection.Connection.

If, for any reason, this class doesn't suit your needs, it's easy to just use vibe.d's ConnectionPool directly. Simply provide it with a delegate that creates a new mysql.connection.Connection and does any other custom processing if needed.

version(IncludeMySQLPool)
class MySQLPool {}

Constructors

this
this(string host, string user, string password, string database, ushort port, uint maxConcurrent, SvrCapFlags capFlags, void delegate(Connection) onNewConnection)
this(string host, string user, string password, string database, ushort port, SvrCapFlags capFlags, void delegate(Connection) onNewConnection)
this(string host, string user, string password, string database, ushort port, void delegate(Connection) onNewConnection)
this(string connStr, uint maxConcurrent, SvrCapFlags capFlags, void delegate(Connection) onNewConnection)
this(string connStr, SvrCapFlags capFlags, void delegate(Connection) onNewConnection)
this(string connStr, void delegate(Connection) onNewConnection)

Sets up a connection pool with the provided connection settings.

Members

Functions

autoRegister
void autoRegister(Prepared prepared)
void autoRegister(string sql)

Set a prepared statement to be automatically registered on all connections received from this pool.

autoRelease
void autoRelease(Prepared prepared)
void autoRelease(string sql)

Set a prepared statement to be automatically released from all connections received from this pool.

clearAllRegistrations
void clearAllRegistrations()

Removes ALL prepared statement autoRegister and autoRelease which have been set.

clearAuto
void clearAuto(Prepared prepared)
void clearAuto(string sql)

Removes any autoRegister or autoRelease which may have been set for this prepared statement.

isAutoCleared
bool isAutoCleared(Prepared prepared)
bool isAutoCleared(string sql)
bool isAutoCleared(Nullable!PreparedInfo info)

Is the given statement set for NEITHER auto-register NOR auto-release on connections obtained from this connection pool?

isAutoRegistered
bool isAutoRegistered(Prepared prepared)
bool isAutoRegistered(string sql)
bool isAutoRegistered(Nullable!PreparedInfo info)

Is the given statement set to be automatically registered on all connections obtained from this connection pool?

isAutoReleased
bool isAutoReleased(Prepared prepared)
bool isAutoReleased(string sql)
bool isAutoReleased(Nullable!PreparedInfo info)

Is the given statement set to be automatically released on all connections obtained from this connection pool?

lockConnection
auto lockConnection()

Obtain a connection. If one isn't available, a new one will be created.

Properties

maxConcurrency
uint maxConcurrency [@property getter]
uint maxConcurrency [@property setter]

Forwards to vibe.d's ConnectionPool.maxConcurrency

onNewConnection
void delegate(Connection) onNewConnection [@property setter]
void delegate(Connection) onNewConnection [@property getter]

Get/set a callback delegate to be run every time a new connection is created.

Meta