C# Class LightningDB.LightningTransaction

Represents a transaction.
Inheritance: IDisposable
Show file Open project: CoreyKaylor/Lightning.NET Class Usage Examples

Public Methods

Method Description
Abort ( ) : void

Abandon all the operations of the transaction instead of saving them. All cursors opened within the transaction will be closed by this call. The cursors and transaction handle will be freed and must not be used again after this call.

BeginTransaction ( ) : LightningTransaction

Begins a child transaction.

BeginTransaction ( TransactionBeginFlags beginFlags ) : LightningTransaction

Begin a child transaction.

Commit ( ) : void

Commit all the operations of a transaction into the database. All cursors opened within the transaction will be closed by this call. The cursors and transaction handle will be freed and must not be used again after this call.

ContainsKey ( LightningDatabase db, byte key ) : bool

Check whether data exists in database.

CreateCursor ( LightningDatabase db ) : LightningDB.LightningCursor

Create a cursor. Cursors are associated with a specific transaction and database and may not span threads.

Delete ( LightningDatabase db, byte key ) : void

Delete items from a database. This function removes key/data pairs from the database. If the database does not support sorted duplicate data items (MDB_DUPSORT) the data parameter is ignored. If the database supports sorted duplicates and the data parameter is NULL, all of the duplicate data items for the key will be deleted. Otherwise, if the data parameter is non-NULL only the matching data item will be deleted. This function will return MDB_NOTFOUND if the specified key/data pair is not in the database.

Delete ( LightningDatabase db, byte key, byte value ) : void

Delete items from a database. This function removes key/data pairs from the database. If the database does not support sorted duplicate data items (MDB_DUPSORT) the data parameter is ignored. If the database supports sorted duplicates and the data parameter is NULL, all of the duplicate data items for the key will be deleted. Otherwise, if the data parameter is non-NULL only the matching data item will be deleted. This function will return MDB_NOTFOUND if the specified key/data pair is not in the database.

Dispose ( ) : void

Dispose this transaction and deallocate all resources associated with it (including databases).

DropDatabase ( LightningDatabase database ) : void

Drops the database.

Equals ( object obj ) : bool
Get ( LightningDatabase db, byte key ) : byte[]

Get value from a database.

GetEntriesCount ( LightningDatabase db ) : long

The number of items in the database.

GetHashCode ( ) : int
Handle ( ) : IntPtr
OpenDatabase ( string name = null, DatabaseConfiguration configuration = null ) : LightningDatabase

Opens a database in context of this transaction.

Put ( LightningDatabase db, byte key, byte value, PutOptions options = PutOptions.None ) : void

Put data into a database.

Renew ( ) : void

Renew current transaction.

Reset ( ) : void

Reset current transaction.

TruncateDatabase ( LightningDatabase database ) : void

Truncates all data from the database.

TryGet ( LightningDatabase db, byte key, byte &value ) : bool

Tries to get a value by its key.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Abort this transaction and deallocate all resources associated with it (including databases).

Private Methods

Method Description
LightningTransaction ( LightningEnvironment environment, LightningTransaction parent, TransactionBeginFlags flags ) : System

Created new instance of LightningTransaction

OnParentStateChanging ( LightningTransactionState state ) : void

Method Details

Abort() public method

Abandon all the operations of the transaction instead of saving them. All cursors opened within the transaction will be closed by this call. The cursors and transaction handle will be freed and must not be used again after this call.
public Abort ( ) : void
return void

BeginTransaction() public method

Begins a child transaction.
public BeginTransaction ( ) : LightningTransaction
return LightningTransaction

BeginTransaction() public method

Begin a child transaction.
public BeginTransaction ( TransactionBeginFlags beginFlags ) : LightningTransaction
beginFlags TransactionBeginFlags Options for a new transaction.
return LightningTransaction

Commit() public method

Commit all the operations of a transaction into the database. All cursors opened within the transaction will be closed by this call. The cursors and transaction handle will be freed and must not be used again after this call.
public Commit ( ) : void
return void

ContainsKey() public method

Check whether data exists in database.
public ContainsKey ( LightningDatabase db, byte key ) : bool
db LightningDatabase Database.
key byte Key.
return bool

CreateCursor() public method

Create a cursor. Cursors are associated with a specific transaction and database and may not span threads.
public CreateCursor ( LightningDatabase db ) : LightningDB.LightningCursor
db LightningDatabase A database.
return LightningDB.LightningCursor

Delete() public method

Delete items from a database. This function removes key/data pairs from the database. If the database does not support sorted duplicate data items (MDB_DUPSORT) the data parameter is ignored. If the database supports sorted duplicates and the data parameter is NULL, all of the duplicate data items for the key will be deleted. Otherwise, if the data parameter is non-NULL only the matching data item will be deleted. This function will return MDB_NOTFOUND if the specified key/data pair is not in the database.
public Delete ( LightningDatabase db, byte key ) : void
db LightningDatabase A database handle returned by mdb_dbi_open()
key byte The key to delete from the database
return void

Delete() public method

Delete items from a database. This function removes key/data pairs from the database. If the database does not support sorted duplicate data items (MDB_DUPSORT) the data parameter is ignored. If the database supports sorted duplicates and the data parameter is NULL, all of the duplicate data items for the key will be deleted. Otherwise, if the data parameter is non-NULL only the matching data item will be deleted. This function will return MDB_NOTFOUND if the specified key/data pair is not in the database.
public Delete ( LightningDatabase db, byte key, byte value ) : void
db LightningDatabase A database handle returned by mdb_dbi_open()
key byte The key to delete from the database
value byte The data to delete (optional)
return void

Dispose() public method

Dispose this transaction and deallocate all resources associated with it (including databases).
public Dispose ( ) : void
return void

Dispose() protected method

Abort this transaction and deallocate all resources associated with it (including databases).
protected Dispose ( bool disposing ) : void
disposing bool True if called from Dispose.
return void

DropDatabase() public method

Drops the database.
public DropDatabase ( LightningDatabase database ) : void
database LightningDatabase
return void

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

Get() public method

Get value from a database.
public Get ( LightningDatabase db, byte key ) : byte[]
db LightningDatabase Database
key byte Key byte array.
return byte[]

GetEntriesCount() public method

The number of items in the database.
public GetEntriesCount ( LightningDatabase db ) : long
db LightningDatabase The database we are counting items in.
return long

GetHashCode() public method

public GetHashCode ( ) : int
return int

Handle() public method

public Handle ( ) : IntPtr
return System.IntPtr

OpenDatabase() public method

Opens a database in context of this transaction.
public OpenDatabase ( string name = null, DatabaseConfiguration configuration = null ) : LightningDatabase
name string Database name (optional). If null then the default name is used.
configuration DatabaseConfiguration Database open options.
return LightningDatabase

Put() public method

Put data into a database.
public Put ( LightningDatabase db, byte key, byte value, PutOptions options = PutOptions.None ) : void
db LightningDatabase Database.
key byte Key byte array.
value byte Value byte array.
options PutOptions Operation options (optional).
return void

Renew() public method

Renew current transaction.
public Renew ( ) : void
return void

Reset() public method

Reset current transaction.
public Reset ( ) : void
return void

TruncateDatabase() public method

Truncates all data from the database.
public TruncateDatabase ( LightningDatabase database ) : void
database LightningDatabase
return void

TryGet() public method

Tries to get a value by its key.
public TryGet ( LightningDatabase db, byte key, byte &value ) : bool
db LightningDatabase Database.
key byte Key byte array.
value byte Value byte array if exists.
return bool