forked from blue/lmdbal
some more transaction thought on cache
This commit is contained in:
parent
f0779ae2aa
commit
8be63d7551
6 changed files with 241 additions and 58 deletions
src
|
@ -31,31 +31,20 @@ LMDBAL::iStorage::~iStorage() {}
|
|||
void LMDBAL::iStorage::drop() {
|
||||
ensureOpened(dropMethodName);
|
||||
|
||||
MDB_txn *txn;
|
||||
int rc = mdb_txn_begin(db->environment, NULL, 0, &txn);
|
||||
if (rc) {
|
||||
mdb_txn_abort(txn);
|
||||
throw Unknown(db->name, mdb_strerror(rc), name);
|
||||
}
|
||||
rc = drop(txn);
|
||||
if (rc) {
|
||||
mdb_txn_abort(txn);
|
||||
TransactionID txn = db->beginTransaction();
|
||||
int rc = drop(txn);
|
||||
if (rc != MDB_SUCCESS) {
|
||||
abortTransaction(txn);
|
||||
throw Unknown(db->name, mdb_strerror(rc), name);
|
||||
}
|
||||
|
||||
mdb_txn_commit(txn);
|
||||
db->commitTransaction(txn);
|
||||
}
|
||||
|
||||
int LMDBAL::iStorage::drop(MDB_txn* transaction) {
|
||||
int LMDBAL::iStorage::drop(TransactionID transaction) {
|
||||
return mdb_drop(transaction, dbi, 0);
|
||||
}
|
||||
|
||||
const std::string & LMDBAL::iStorage::dbName() const {
|
||||
return db->name;}
|
||||
|
||||
bool LMDBAL::iStorage::isDBOpened() const {
|
||||
return db->opened;}
|
||||
|
||||
void LMDBAL::iStorage::ensureOpened(const std::string& methodName) const {
|
||||
if (!db->opened)
|
||||
throw Closed(methodName, db->name, name);
|
||||
|
@ -80,10 +69,8 @@ LMDBAL::SizeType LMDBAL::iStorage::count() const {
|
|||
LMDBAL::SizeType LMDBAL::iStorage::count(TransactionID txn) const {
|
||||
MDB_stat stat;
|
||||
int rc = mdb_stat(txn, dbi, &stat);
|
||||
if (rc) {
|
||||
mdb_txn_abort(txn);
|
||||
if (rc != MDB_SUCCESS)
|
||||
throw Unknown(db->name, mdb_strerror(rc), name);
|
||||
}
|
||||
|
||||
return stat.ms_entries;
|
||||
}
|
||||
|
@ -117,6 +104,12 @@ void LMDBAL::iStorage::throwUnknown(int rc, LMDBAL::TransactionID txn) const {
|
|||
throwUnknown(rc);
|
||||
}
|
||||
|
||||
const std::string & LMDBAL::iStorage::dbName() const {
|
||||
return db->name;}
|
||||
|
||||
bool LMDBAL::iStorage::isDBOpened() const {
|
||||
return db->opened;}
|
||||
|
||||
void LMDBAL::iStorage::throwUnknown(int rc) const {
|
||||
throw Unknown(db->name, mdb_strerror(rc), name);}
|
||||
|
||||
|
@ -135,19 +128,18 @@ LMDBAL::TransactionID LMDBAL::iStorage::beginTransaction() const {
|
|||
void LMDBAL::iStorage::abortTransaction(LMDBAL::TransactionID id) const {
|
||||
db->abortPrivateTransaction(id, name);}
|
||||
|
||||
void LMDBAL::iStorage::commitTransaction(LMDBAL::TransactionID id) const {
|
||||
void LMDBAL::iStorage::commitTransaction(LMDBAL::TransactionID id) {
|
||||
db->commitPrivateTransaction(id, name);}
|
||||
|
||||
void LMDBAL::iStorage::transactionStarted(LMDBAL::TransactionID txn, bool readOnly) const {
|
||||
UNUSED(txn);
|
||||
UNUSED(readOnly);
|
||||
}
|
||||
void LMDBAL::iStorage::transactionCommited(LMDBAL::TransactionID txn) const {
|
||||
UNUSED(txn);
|
||||
}
|
||||
void LMDBAL::iStorage::transactionCommited(LMDBAL::TransactionID txn) {
|
||||
UNUSED(txn);}
|
||||
|
||||
void LMDBAL::iStorage::transactionAborted(LMDBAL::TransactionID txn) const {
|
||||
UNUSED(txn);
|
||||
}
|
||||
UNUSED(txn);}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue