C# Class Azavea.Open.DAO.SQL.DbConnectionCache

Holds connections, using the connection descriptor to determine what request wants what connection.
Datei anzeigen Open project: azavea/net-dao

Public Methods

Method Description
Get ( AbstractSqlConnectionDescriptor connDesc ) : IDbConnection

This returns a connection from the cache, or creates a new one if necessary. This method is thread safe. This method improved one test's performance (the only one I measured) by about 20%. Since some databases cannot have more than one connection at a time, we ask the connection descriptor whether we can actually cache the connection or not.

Return ( AbstractSqlConnectionDescriptor connDesc, IDbConnection conn ) : void

Inserts the connection into the cache IF we don't have one already (we only cache one connection per unique descriptor). This method is thread safe. Due to MS Access not allowing more than one connection to have the DB locked for modifying at one time, any connections to Access DBs are closed and not cached.

Method Details

Get() public method

This returns a connection from the cache, or creates a new one if necessary. This method is thread safe. This method improved one test's performance (the only one I measured) by about 20%. Since some databases cannot have more than one connection at a time, we ask the connection descriptor whether we can actually cache the connection or not.
public Get ( AbstractSqlConnectionDescriptor connDesc ) : IDbConnection
connDesc AbstractSqlConnectionDescriptor
return IDbConnection

Return() public method

Inserts the connection into the cache IF we don't have one already (we only cache one connection per unique descriptor). This method is thread safe. Due to MS Access not allowing more than one connection to have the DB locked for modifying at one time, any connections to Access DBs are closed and not cached.
public Return ( AbstractSqlConnectionDescriptor connDesc, IDbConnection conn ) : void
connDesc AbstractSqlConnectionDescriptor
conn IDbConnection
return void