#include <cachedDatabase.h>
Public Member Functions | |
virtual | ~CachedDatabase () |
Deletes the cache prototype and the decorated Database instance. | |
virtual void | commit () |
Commits transactions on all connections. | |
virtual void | rollback () |
Rolls back transactions on all connections. | |
virtual Connection * | getConnection (const std::string &connStr) |
Creates a new connection to this database. | |
virtual void | returnConnection (Connection *connection) |
Releases the connection created with Database::getConnection(). | |
virtual void | disconnect () |
Commits all connections on the database, then disconnects them from database. | |
virtual DatabaseImpl * | getImplementation () |
Returns the driver-side part of the Database implemenation. | |
virtual Database * | getBasicDatabase () |
Returns the driver-independent part of the Database implementation. | |
virtual Driver & | getDriver () |
Returns a reference to a Driver associated with this database. |
To use it, pass a prototype of a Cache implementation to the constructor. Consequent calls to getConnection() will clone the prototype, create a new CachedConnection instance and pass this clone to it.
Connection * iopc::CachedDatabase::getConnection | ( | const std::string & | connStr | ) | [virtual] |
Creates a new connection to this database.
Connection must be opened by calling Connection::open() before executing any SQL commands.
connStr | A connection string. Its format is defined by the database driver. Usually it identifies the database user/schema. |
Implements iopc::Database.
void iopc::CachedDatabase::returnConnection | ( | Connection * | connection | ) | [virtual] |
Releases the connection created with Database::getConnection().
Any connection that was created using Database::getConnection() must be passed to this method when no longer needed.
connection | The connection to be released |
Implements iopc::Database.
void iopc::CachedDatabase::disconnect | ( | ) | [virtual] |
Commits all connections on the database, then disconnects them from database.
The connections are removed from the connection set. (No returnConnection() is needed)
Implements iopc::Database.