#include <cachedConnection.h>
Public Member Functions | |
void | stopCache () |
Empties and stops the associated cache. | |
void | restartCache () |
Starts the stopped cache. | |
virtual | ~CachedConnection () |
Deletes the inner (decorated) Connection instance and the associated Cache. | |
virtual Cursor * | sql (const std::string &name) |
Calls Cache::updateDirty() before performing Cursor::sql(). | |
virtual Cursor * | sqlNoCache (const std::string &name) |
Executes an SQL statement while not notifying the associated cache. | |
virtual void | returnCursor (Cursor *cur) |
Cursors that are no longer needed should be returned to the driver Connection object using this method. | |
virtual void | closeAllCursors () |
Closes and returns all cursors on this connection. | |
virtual void | sqlNonQuery (const std::string &name) |
Calls Cache::updateDirty() before performing Cursor::sqlNonQuery(). | |
virtual void | sqlNonQueryNoCache (const std::string &name) |
Executes an SQL statement while not notifying the associated cache. | |
virtual void | commit () |
Calls Cache::updateDirty() before performing Cursor::commit(). | |
virtual void | rollback () |
Calls Cache::removeAll() before performing Cursor::rollback(). | |
virtual void | savepoint (const std::string &name) |
Calls Cache::updateDirty() before performing Cursor::savepoint(). | |
virtual void | rollbackToSavepoint (const std::string &name) |
Calls Cache::removeAll() before performing Cursor::rollbackToSavepoint(). | |
virtual void | open () |
Opens the connection. | |
virtual void | close () |
Closes the connection. | |
virtual void | disconnect () |
Commits last transaction and closes the connection. | |
virtual void | abort () |
Rolls back current transaction and closes the connection. | |
virtual void | setAutoCommit (bool ac) |
Turns autocommit on this connection on or off. | |
virtual bool | isOpened () |
Determines whether this connection is opened or not. | |
virtual Connection & | operator<< (const std::string &command) |
Shortcut for sqlNonQuery. | |
Database & | getDatabase () |
Returns the associated Database object. | |
Driver & | getDriver () |
Returns the database driver used. | |
virtual void | updateDirty () |
Invokes Cache::updateDirty() on the associated Cache. | |
virtual void | removeAll () |
Invokes Cache::removeAll() on the associated Cache. | |
ConnectionImpl * | getImplementation () |
Returns the driver-side part of the Connection implemenation. | |
virtual Connection * | getBasicConnection () |
Returns the driver-independent part of the Connection implementation. | |
CacheLock & | makePersistent (const PersIdentification &persId, DatabaseObject &objectPtr) |
Transfers the referenced object ownership to the associated cache. | |
CacheLock & | getCacheLock (const PersIdentification &persId, bool rdonly=false) |
Locks the specified object in the associated cache. | |
void | dbDelete (const PersIdentification &persId) |
Removes a persistent object identified by persId from database and from an associated cache. | |
void | cacheDelete (const PersIdentification &persId) |
Hints cache to drop its copy of the object identified by persId. | |
virtual Connection * | getInnerConnection () |
Returns the decorated connection. | |
Cache & | getCache () |
Returns the associated cache. |
Each instance of CachedConnection has an associated Cache. Behaviour of most of the Connection methods is modified to notify the cache on various events. For example it tells the cache that it should write all cached local copies into database before commit is performed. It also provides several proxy methods such as dbDelete(), cacheDelete(), makePersistent(), getCacheLock() that invoke corresponding actions on the associated cache.
void iopc::CachedConnection::stopCache | ( | ) |
Empties and stops the associated cache.
void iopc::CachedConnection::restartCache | ( | ) |
Starts the stopped cache.
Cursor * iopc::CachedConnection::sql | ( | const std::string & | name | ) | [virtual] |
Calls Cache::updateDirty() before performing Cursor::sql().
Implements iopc::Connection.
Cursor * iopc::CachedConnection::sqlNoCache | ( | const std::string & | name | ) | [virtual] |
void iopc::CachedConnection::returnCursor | ( | Cursor * | cur | ) | [virtual] |
Cursors that are no longer needed should be returned to the driver Connection object using this method.
All resources allocated by the Cursor are released.
Implements iopc::Connection.
void iopc::CachedConnection::sqlNonQuery | ( | const std::string & | name | ) | [virtual] |
Calls Cache::updateDirty() before performing Cursor::sqlNonQuery().
Implements iopc::Connection.
void iopc::CachedConnection::sqlNonQueryNoCache | ( | const std::string & | name | ) | [virtual] |
void iopc::CachedConnection::commit | ( | ) | [virtual] |
Calls Cache::updateDirty() before performing Cursor::commit().
Implements iopc::Connection.
void iopc::CachedConnection::rollback | ( | ) | [virtual] |
Calls Cache::removeAll() before performing Cursor::rollback().
Implements iopc::Connection.
void iopc::CachedConnection::savepoint | ( | const std::string & | name | ) | [virtual] |
Calls Cache::updateDirty() before performing Cursor::savepoint().
Implements iopc::Connection.
void iopc::CachedConnection::rollbackToSavepoint | ( | const std::string & | name | ) | [virtual] |
Calls Cache::removeAll() before performing Cursor::rollbackToSavepoint().
Implements iopc::Connection.
void iopc::CachedConnection::open | ( | ) | [virtual] |
void iopc::CachedConnection::close | ( | ) | [virtual] |
Closes the connection.
This call should close the physical link to the DBMS
Implements iopc::Connection.
void iopc::CachedConnection::disconnect | ( | ) | [virtual] |
Commits last transaction and closes the connection.
The connection still needs to be returned to associated Database object
Implements iopc::Connection.
void iopc::CachedConnection::setAutoCommit | ( | bool | ac | ) | [virtual] |
Turns autocommit on this connection on or off.
ac | - true - autocommit is enabled, false - autocommit is disabled |
Implements iopc::Connection.
virtual void iopc::CachedConnection::updateDirty | ( | ) | [inline, virtual] |
Invokes Cache::updateDirty() on the associated Cache.
Synchronizes the state of cache and DB by updating the DB.
virtual void iopc::CachedConnection::removeAll | ( | ) | [inline, virtual] |
Invokes Cache::removeAll() on the associated Cache.
Synchronizes the state of cache and DB by discarding all managed object (no modifications are written to the DB).
CacheLock & iopc::CachedConnection::makePersistent | ( | const PersIdentification & | persId, | |
DatabaseObject & | objectPtr | |||
) |
Transfers the referenced object ownership to the associated cache.
persId | Identity of the object | |
objectPtr | The persistent object |
CacheLock & iopc::CachedConnection::getCacheLock | ( | const PersIdentification & | persId, | |
bool | rdonly = false | |||
) |
Locks the specified object in the associated cache.
persId | Identity of the object to be locked | |
rdonly | Determines if a shared read-only lock should be placed on the object in the cache. |