DBXTalk / Garage
Project infos
| License | MIT |
| Tags | database, opendbx, sqlite, mysql, db, relational database, sqlite3, postgresql, pharo |
| Creation date | 2015-04-16 |
| Website | http://guillep.github.io/DBXTalk/garage/ |
Monticello registration
About Garage
Garage is the relational database driver for the Pharo language. Garage provides a common API to connect with several database servers in a coherent way (JDBC like). Along with Garage, we provide implementations of several database drivers.
Packages
- ConfigurationOfGarage: basic configuration
- Garage: common driver API
- Garage-Mysql: implementation of the mysql driver based on the code in here
- Garage-OpenDBX: implementation of the opendbx driver
- Garage-Postgres: implementation using the PostgresV2 driver
- Garage-Sqlite3: implementation based on the NBSqlite3 driver
- Garage-ConnectionPool: connection pool implementation
Connection Pool
I am a connection pool of GADriver connections. I create connections lazily as they are needed in a batched way. If no more connections are available and I reached the maximum amount of alive connections, I try to purge connections and if not I throw an exception when a connection is demanded.
I have the following main properties:
- maxIdleConnections: the maximum amount of unused connections that I handle. Default: 20.
- maxConnections: the maximum amount of connections I will keep alive in total (idle or not). Default: 20.
- growSize: it specifies the amount of connections to be created when no more free connections are available. Default: 5.
- validationBlock: a Block to specify an arbitrary expression to check if the connection is valid or not. A connection is considered not valid is the validation block throws an exception.
This connection pool returns a GAPooledConnection, polymorphic to a GADriver. Upon close, the pooled connection is returned to the pool. The connection pool tries to purge itself and remove unused connections when the number of returned connections since the last purge arrives to the number of idle connections that should be discardable (maxidleconnections - maxconnections).
Example of usage:
pool := GAConnectionPool forConnectionString: Fixture connectionString. pool maxConnections: 1. connection := pool getConnection.
