C# Class LightningDB.LightningEnvironment

LMDB Environment.
Inheritance: IClosingEventSource, IDisposable
显示文件 Open project: CoreyKaylor/Lightning.NET Class Usage Examples

Public Methods

Method Description
BeginTransaction ( ) : LightningTransaction

Create a transaction for use with the environment. The transaction handle may be discarded using Abort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.

BeginTransaction ( LightningTransaction parent, TransactionBeginFlags beginFlags ) : LightningTransaction

Create a transaction for use with the environment. The transaction handle may be discarded using Abort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.

BeginTransaction ( TransactionBeginFlags beginFlags ) : LightningTransaction

Create a transaction for use with the environment. The transaction handle may be discarded usingAbort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.

CopyTo ( string path, bool compact = false ) : void

Copy an MDB environment to the specified path. This function may be used to make a backup of an existing environment.

Dispose ( ) : void

Dispose the environment and release the memory map. Only a single thread may call this function. All transactions, databases, and cursors must already be closed before calling this function. Attempts to use any such handles after calling this function will cause a SIGSEGV. The environment handle will be freed and must not be used again after this call.

Flush ( bool force ) : void

Flush the data buffers to disk. Data is always written to disk when LightningTransaction.Commit is called, but the operating system may keep it buffered. MDB always flushes the OS buffers upon commit as well, unless the environment was opened with EnvironmentOpenFlags.NoSync or in part EnvironmentOpenFlags.NoMetaSync.

Handle ( ) : IntPtr
LightningEnvironment ( string path, LightningDB.EnvironmentConfiguration configuration = null ) : System

Creates a new instance of LightningEnvironment.

Open ( EnvironmentOpenFlags openFlags = EnvironmentOpenFlags.None, UnixAccessMode accessMode = UnixAccessMode.Default ) : void

Open the environment.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Disposes the environment and deallocates all resources associated with it.

Private Methods

Method Description
EnsureOpened ( ) : void

Method Details

BeginTransaction() public method

Create a transaction for use with the environment. The transaction handle may be discarded using Abort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.
public BeginTransaction ( ) : LightningTransaction
return LightningTransaction

BeginTransaction() public method

Create a transaction for use with the environment. The transaction handle may be discarded using Abort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.
public BeginTransaction ( LightningTransaction parent, TransactionBeginFlags beginFlags ) : LightningTransaction
parent LightningTransaction /// If this parameter is non-NULL, the new transaction will be a nested transaction, with the transaction indicated by parent as its parent. /// Transactions may be nested to any level. /// A parent transaction may not issue any other operations besides BeginTransaction, Abort, or Commit while it has active child transactions. ///
beginFlags TransactionBeginFlags /// Special options for this transaction. ///
return LightningTransaction

BeginTransaction() public method

Create a transaction for use with the environment. The transaction handle may be discarded usingAbort() or Commit(). Note: Transactions may not span threads; a transaction must only be used by a single thread. Also, a thread may only have a single transaction. Cursors may not span transactions; each cursor must be opened and closed within a single transaction.
public BeginTransaction ( TransactionBeginFlags beginFlags ) : LightningTransaction
beginFlags TransactionBeginFlags /// Special options for this transaction. ///
return LightningTransaction

CopyTo() public method

Copy an MDB environment to the specified path. This function may be used to make a backup of an existing environment.
public CopyTo ( string path, bool compact = false ) : void
path string The directory in which the copy will reside. This directory must already exist and be writable but must otherwise be empty.
compact bool Omit empty pages when copying.
return void

Dispose() public method

Dispose the environment and release the memory map. Only a single thread may call this function. All transactions, databases, and cursors must already be closed before calling this function. Attempts to use any such handles after calling this function will cause a SIGSEGV. The environment handle will be freed and must not be used again after this call.
public Dispose ( ) : void
return void

Dispose() protected method

Disposes the environment and deallocates all resources associated with it.
protected Dispose ( bool disposing ) : void
disposing bool True if called from Dispose.
return void

Flush() public method

Flush the data buffers to disk. Data is always written to disk when LightningTransaction.Commit is called, but the operating system may keep it buffered. MDB always flushes the OS buffers upon commit as well, unless the environment was opened with EnvironmentOpenFlags.NoSync or in part EnvironmentOpenFlags.NoMetaSync.
public Flush ( bool force ) : void
force bool If true, force a synchronous flush. Otherwise if the environment has the EnvironmentOpenFlags.NoSync flag set the flushes will be omitted, and with MDB_MAPASYNC they will be asynchronous.
return void

Handle() public method

public Handle ( ) : IntPtr
return System.IntPtr

LightningEnvironment() public method

Creates a new instance of LightningEnvironment.
public LightningEnvironment ( string path, LightningDB.EnvironmentConfiguration configuration = null ) : System
path string Directory for storing database files.
configuration LightningDB.EnvironmentConfiguration Configuration for the environment.
return System

Open() public method

Open the environment.
public Open ( EnvironmentOpenFlags openFlags = EnvironmentOpenFlags.None, UnixAccessMode accessMode = UnixAccessMode.Default ) : void
openFlags EnvironmentOpenFlags
accessMode UnixAccessMode
return void