libmdbx  0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
mdbx::env Class Reference

Unmanaged database environment. More...

#include <mdbx.h++>

Inherited by mdbx::env_managed.

Classes

struct  geometry
 Database geometry for size management. More...
 
struct  limits
 
struct  operate_options
 Operate options. More...
 
struct  operate_parameters
 Operate parameters. More...
 
struct  reader_info
 Reader information. More...
 
struct  reclaiming_options
 Garbage reclaiming options. More...
 

Public Types

enum  mode { readonly, write_file_io, write_mapped_io }
 Operation mode. More...
 
enum  durability { robust_synchronous, half_synchronous_weak_last, lazy_weak_tail, whole_fragile }
 Durability level. More...
 
enum  remove_mode { just_remove = MDBX_ENV_JUST_DELETE, ensure_unused = MDBX_ENV_ENSURE_UNUSED, wait_for_unused = MDBX_ENV_WAIT_FOR_UNUSED }
 Deletion modes for remove(). More...
 
using stat = ::MDBX_stat
 Statistics for a database in the MDBX environment. More...
 
using info = ::MDBX_envinfo
 Information about the environment. More...
 

Public Member Functions

MDBX_CXX11_CONSTEXPR env () noexcept=default
 
 env (const env &) noexcept=default
 
envoperator= (env &&other) noexcept
 
 env (env &&other) noexcept
 
 ~env () noexcept
 
MDBX_CXX14_CONSTEXPR operator bool () const noexcept
 
MDBX_CXX14_CONSTEXPR operator const MDBX_env * () const
 
MDBX_CXX14_CONSTEXPR operator MDBX_env * ()
 
env::operate_parameters get_operation_parameters () const
 Returns current operation parameters. More...
 
env::mode get_mode () const
 Returns current operation mode. More...
 
env::durability get_durability () const
 Returns current durability mode. More...
 
env::reclaiming_options get_reclaiming () const
 Returns current reclaiming options. More...
 
env::operate_options get_options () const
 Returns current operate options. More...
 
bool is_pristine () const
 Returns true for a freshly created database, but false if at least one transaction was committed. More...
 
bool is_empty () const
 Checks whether the database is empty. More...
 
size_t dbsize_min () const
 Returns the minimal database size in bytes for the environment. More...
 
size_t dbsize_max () const
 Returns the maximal database size in bytes for the environment. More...
 
size_t key_min (key_mode mode) const noexcept
 Returns the minimal key size in bytes for specified keys mode. More...
 
size_t key_max (key_mode mode) const
 Returns the maximal key size in bytes for specified keys mode. More...
 
size_t value_min (value_mode mode) const noexcept
 Returns the minimal value size in bytes for specified values mode. More...
 
size_t value_max (value_mode mode) const
 Returns the maximal value size in bytes for specified values mode. More...
 
size_t transaction_size_max () const
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. More...
 
envcopy (const MDBX_STD_FILESYSTEM_PATH &destination, bool compactify, bool force_dynamic_size=false)
 Make a copy (backup) of an existing environment to the specified path. More...
 
envcopy (const ::std::string &destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (filehandle fd, bool compactify, bool force_dynamic_size=false)
 Copy an environment to the specified file descriptor. More...
 
stat get_stat () const
 Returns snapshot statistics about the MDBX environment. More...
 
size_t get_pagesize () const
 Returns pagesize of this MDBX environment. More...
 
info get_info () const
 Return snapshot information about the MDBX environment. More...
 
stat get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction. More...
 
info get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction. More...
 
filehandle get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment. More...
 
path get_path () const
 Return the path that was used for opening the environment. More...
 
MDBX_env_flags_t get_flags () const
 Returns environment flags. More...
 
unsigned max_readers () const
 Returns the maximum number of threads/reader slots for the environment. More...
 
unsigned max_maps () const
 Returns the maximum number of named databases for the environment. More...
 
void * get_context () const noexcept
 Returns the application context associated with the environment. More...
 
envset_context (void *)
 Sets the application context associated with the environment. More...
 
envset_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envalter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags. More...
 
envset_geometry (const geometry &size)
 Set all size-related parameters of environment. More...
 
bool sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers. More...
 
bool poll_sync_to_disk ()
 Performs non-blocking polling of sync-to-disk thresholds. More...
 
void close_map (const map_handle &)
 Close a key-value map (aka sub-database) handle. Normally unnecessary. More...
 
template<typename VISITOR >
int enumerate_readers (VISITOR &visitor)
 Enumerate readers. More...
 
unsigned check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots. More...
 
envset_HandleSlowReaders (MDBX_hsr_func *)
 Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
MDBX_hsr_funcget_HandleSlowReaders () const noexcept
 Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
txn_managed start_read () const
 Starts read (read-only) transaction. More...
 
txn_managed prepare_read () const
 Creates but not start read transaction. More...
 
txn_managed start_write (bool dont_wait=false)
 Starts write (read-write) transaction. More...
 
txn_managed try_start_write ()
 Tries to start write (read-write) transaction without blocking. More...
 

Static Public Member Functions

static size_t default_pagesize () noexcept
 Returns default page size for current system/platform. More...
 
static bool remove (const MDBX_STD_FILESYSTEM_PATH &, const remove_mode mode=just_remove)
 Removes the environment's files in a proper and multiprocess-safe way. More...
 
static bool remove (const ::std::string &, const remove_mode mode=just_remove)
 

Protected Member Functions

MDBX_CXX11_CONSTEXPR env (MDBX_env *ptr) noexcept
 

Protected Attributes

MDBX_envhandle_ {nullptr}
 

Friends

class txn
 
MDBX_CXX11_CONSTEXPR bool operator== (const env &a, const env &b) noexcept
 
MDBX_CXX11_CONSTEXPR bool operator!= (const env &a, const env &b) noexcept
 

Detailed Description

Unmanaged database environment.

Like other unmanaged classes, env allows copying and assignment for instances, but does not destroys the represented underlying object from the own class destructor.

An environment supports multiple key-value sub-databases (aka key-value spaces or tables), all residing in the same shared-memory map.

Member Typedef Documentation

◆ info

Information about the environment.

◆ stat

Statistics for a database in the MDBX environment.

Member Enumeration Documentation

◆ durability

Durability level.

Enumerator
robust_synchronous 

Default robust and durable sync mode.

Metadata is written and flushed to disk after a data is written and flushed, which guarantees the integrity of the database in the event of a crash at any time.

Attention
Please do not use other modes until you have studied all the details and are sure. Otherwise, you may lose your users' data, as happens in Miranda NG messenger.
half_synchronous_weak_last 

Don't sync the meta-page after commit.

Flush system buffers to disk only once per transaction commit, omit the metadata flush. Defer that until the system flushes files to disk, or next non-MDBX_RDONLY commit or mdbx_env_sync(). Depending on the platform and hardware, with MDBX_NOMETASYNC you may get a doubling of write performance.

This trade-off maintains database integrity, but a system crash may undo the last committed transaction. I.e. it preserves the ACI (atomicity, consistency, isolation) but not D (durability) database property.

MDBX_NOMETASYNC flag may be changed at any time using mdbx_env_set_flags() or by passing to mdbx_txn_begin() for particular write transaction.

See also
SYNC MODES
lazy_weak_tail 

Don't sync anything but keep previous steady commits.

Like MDBX_UTTERLY_NOSYNC the MDBX_SAFE_NOSYNC flag disable similarly flush system buffers to disk when committing a transaction. But there is a huge difference in how are recycled the MVCC snapshots corresponding to previous "steady" transactions (see below).

With MDBX_WRITEMAP the MDBX_SAFE_NOSYNC instructs MDBX to use asynchronous mmap-flushes to disk. Asynchronous mmap-flushes means that actually all writes will scheduled and performed by operation system on it own manner, i.e. unordered. MDBX itself just notify operating system that it would be nice to write data to disk, but no more.

Depending on the platform and hardware, with MDBX_SAFE_NOSYNC you may get a multiple increase of write performance, even 10 times or more.

In contrast to MDBX_UTTERLY_NOSYNC mode, with MDBX_SAFE_NOSYNC flag MDBX will keeps untouched pages within B-tree of the last transaction "steady" which was synced to disk completely. This has big implications for both data durability and (unfortunately) performance:

  • a system crash can't corrupt the database, but you will lose the last transactions; because MDBX will rollback to last steady commit since it kept explicitly.
  • the last steady transaction makes an effect similar to "long-lived" read transaction (see above in the Restrictions & Caveats section) since prevents reuse of pages freed by newer write transactions, thus the any data changes will be placed in newly allocated pages.
  • to avoid rapid database growth, the system will sync data and issue a steady commit-point to resume reuse pages, each time there is insufficient space and before increasing the size of the file on disk.

In other words, with MDBX_SAFE_NOSYNC flag MDBX insures you from the whole database corruption, at the cost increasing database size and/or number of disk IOPs. So, MDBX_SAFE_NOSYNC flag could be used with mdbx_env_sync() as alternatively for batch committing or nested transaction (in some cases). As well, auto-sync feature exposed by mdbx_env_set_syncbytes() and mdbx_env_set_syncperiod() functions could be very useful with MDBX_SAFE_NOSYNC flag.

The number and volume of of disk IOPs with MDBX_SAFE_NOSYNC flag will exactly the as without any no-sync flags. However, you should expect a larger process's work set and significantly worse a locality of reference, due to the more intensive allocation of previously unused pages and increase the size of the database.

MDBX_SAFE_NOSYNC flag may be changed at any time using mdbx_env_set_flags() or by passing to mdbx_txn_begin() for particular write transaction.

whole_fragile 

Don't sync anything and wipe previous steady commits.

Don't flush system buffers to disk when committing a transaction. This optimization means a system crash can corrupt the database, if buffers are not yet flushed to disk. Depending on the platform and hardware, with MDBX_UTTERLY_NOSYNC you may get a multiple increase of write performance, even 100 times or more.

If the filesystem preserves write order (which is rare and never provided unless explicitly noted) and the MDBX_WRITEMAP and MDBX_LIFORECLAIM flags are not used, then a system crash can't corrupt the database, but you can lose the last transactions, if at least one buffer is not yet flushed to disk. The risk is governed by how often the system flushes dirty buffers to disk and how often mdbx_env_sync() is called. So, transactions exhibit ACI (atomicity, consistency, isolation) properties and only lose D (durability). I.e. database integrity is maintained, but a system crash may undo the final transactions.

Otherwise, if the filesystem not preserves write order (which is typically) or MDBX_WRITEMAP or MDBX_LIFORECLAIM flags are used, you should expect the corrupted database after a system crash.

So, most important thing about MDBX_UTTERLY_NOSYNC:

  • a system crash immediately after commit the write transaction high likely lead to database corruption.
  • successful completion of mdbx_env_sync(force = true) after one or more committed transactions guarantees consistency and durability.
  • BUT by committing two or more transactions you back database into a weak state, in which a system crash may lead to database corruption! In case single transaction after mdbx_env_sync, you may lose transaction itself, but not a whole database.

Nevertheless, MDBX_UTTERLY_NOSYNC provides "weak" durability in case of an application crash (but no durability on system failure), and therefore may be very useful in scenarios where data durability is not required over a system failure (e.g for short-lived data), or if you can take such risk.

MDBX_UTTERLY_NOSYNC flag may be changed at any time using mdbx_env_set_flags(), but don't has effect if passed to mdbx_txn_begin() for particular write transaction.

See also
SYNC MODES

◆ mode

Operation mode.

Enumerator
readonly 

Read only mode.

Open the environment in read-only mode. No write operations will be allowed. MDBX will still modify the lock file - except on read-only filesystems, where MDBX does not use locks.

  • with MDBX_RDONLY = open environment in read-only mode. MDBX supports pure read-only mode (i.e. without opening LCK-file) only when environment directory and/or both files are not writable (and the LCK-file may be missing). In such case allowing file(s) to be placed on a network read-only share.
  • without MDBX_RDONLY = open environment in read-write mode.

This flag affects only at environment opening but can't be changed after.

write_file_io 
write_mapped_io 

Map data into memory with write permission.

Use a writeable memory map unless MDBX_RDONLY is set. This uses fewer mallocs and requires much less work for tracking database pages, but loses protection from application bugs like wild pointer writes and other bad updates into the database. This may be slightly faster for DBs that fit entirely in RAM, but is slower for DBs larger than RAM. Also adds the possibility for stray application writes thru pointers to silently corrupt the database.

  • with MDBX_WRITEMAP = all data will be mapped into memory in the read-write mode. This offers a significant performance benefit, since the data will be modified directly in mapped memory and then flushed to disk by single system call, without any memory management nor copying.
  • without MDBX_WRITEMAP = data will be mapped into memory in the read-only mode. This requires stocking all modified database pages in memory and then writing them to disk through file operations.
Warning
On the other hand, MDBX_WRITEMAP adds the possibility for stray application writes thru pointers to silently corrupt the database.
Note
The MDBX_WRITEMAP mode is incompatible with nested transactions, since this is unreasonable. I.e. nested transactions requires mallocation of database pages and more work for tracking ones, which neuters a performance boost caused by the MDBX_WRITEMAP mode.

This flag affects only at environment opening but can't be changed after.

◆ remove_mode

Deletion modes for remove().

Enumerator
just_remove 

Just delete the environment's files and directory if any.

Note
On POSIX systems, processes already working with the database will continue to work without interference until it close the environment.
On Windows, the behavior of just_remove is different because the system does not support deleting files that are currently memory mapped.
ensure_unused 

Make sure that the environment is not being used by other processes, or return an error otherwise.

wait_for_unused 

Wait until other processes closes the environment before deletion.

Constructor & Destructor Documentation

◆ env() [1/4]

MDBX_CXX11_CONSTEXPR mdbx::env::env ( MDBX_env ptr)
protectednoexcept

◆ env() [2/4]

MDBX_CXX11_CONSTEXPR mdbx::env::env ( )
defaultnoexcept

◆ env() [3/4]

mdbx::env::env ( const env )
defaultnoexcept

◆ env() [4/4]

mdbx::env::env ( env &&  other)
inlinenoexcept

◆ ~env()

mdbx::env::~env ( )
inlinenoexcept

Member Function Documentation

◆ alter_flags()

env & mdbx::env::alter_flags ( MDBX_env_flags_t  flags,
bool  on_off 
)
inline

Alter environment flags.

◆ check_readers()

unsigned mdbx::env::check_readers ( )
inline

Checks for stale readers in the lock table and return number of cleared slots.

◆ close_map()

void mdbx::env::close_map ( const map_handle handle)
inline

Close a key-value map (aka sub-database) handle. Normally unnecessary.

Closing a database handle is not necessary, but lets txn::open_map() reuse the handle value. Usually it's better to set a bigger env::operate_parameters::max_maps, unless that value would be large.

Note
Use with care. This call is synchronized via mutex with other calls close_map(), but NOT with other transactions running by other threads. The "next" version of libmdbx (MithrilDB) will solve this issue.

Handles should only be closed if no other threads are going to reference the database handle or one of its cursors any further. Do not close a handle if an existing transaction has modified its database. Doing so can cause misbehavior from database corruption to errors like MDBX_BAD_DBI (since the DB name is gone).

◆ copy() [1/3]

env& mdbx::env::copy ( const ::std::string &  destination,
bool  compactify,
bool  force_dynamic_size = false 
)

◆ copy() [2/3]

env& mdbx::env::copy ( const MDBX_STD_FILESYSTEM_PATH destination,
bool  compactify,
bool  force_dynamic_size = false 
)

Make a copy (backup) of an existing environment to the specified path.

◆ copy() [3/3]

env& mdbx::env::copy ( filehandle  fd,
bool  compactify,
bool  force_dynamic_size = false 
)

Copy an environment to the specified file descriptor.

◆ dbsize_max()

size_t mdbx::env::dbsize_max ( ) const
inline

Returns the maximal database size in bytes for the environment.

◆ dbsize_min()

size_t mdbx::env::dbsize_min ( ) const
inline

Returns the minimal database size in bytes for the environment.

◆ default_pagesize()

static size_t mdbx::env::default_pagesize ( )
inlinestaticnoexcept

Returns default page size for current system/platform.

◆ enumerate_readers()

template<typename VISITOR >
int mdbx::env::enumerate_readers ( VISITOR &  visitor)
inline

Enumerate readers.

The VISITOR class must have int operator(const reader_info&, int serial) which should return continue_loop (zero) to continue enumeration, or any non-zero value to exit.

Returns
The last value returned from visitor' functor.

◆ get_context()

void * mdbx::env::get_context ( ) const
inlinenoexcept

Returns the application context associated with the environment.

◆ get_durability()

env::durability mdbx::env::get_durability ( ) const
inline

Returns current durability mode.

◆ get_filehandle()

filehandle mdbx::env::get_filehandle ( ) const
inline

Returns the file descriptor for the DXB file of MDBX environment.

◆ get_flags()

MDBX_env_flags_t mdbx::env::get_flags ( ) const
inline

Returns environment flags.

◆ get_HandleSlowReaders()

MDBX_hsr_func * mdbx::env::get_HandleSlowReaders ( ) const
inlinenoexcept

Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.

See also
set_HandleSlowReaders()

◆ get_info() [1/2]

env::info mdbx::env::get_info ( ) const
inline

Return snapshot information about the MDBX environment.

◆ get_info() [2/2]

env::info mdbx::env::get_info ( const txn txn) const
inline

Return information about the MDBX environment accordingly to the specified transaction.

◆ get_mode()

env::mode mdbx::env::get_mode ( ) const
inline

Returns current operation mode.

◆ get_operation_parameters()

env::operate_parameters mdbx::env::get_operation_parameters ( ) const
inline

Returns current operation parameters.

◆ get_options()

env::operate_options mdbx::env::get_options ( ) const
inline

Returns current operate options.

◆ get_pagesize()

size_t mdbx::env::get_pagesize ( ) const
inline

Returns pagesize of this MDBX environment.

◆ get_path()

path mdbx::env::get_path ( ) const

Return the path that was used for opening the environment.

◆ get_reclaiming()

env::reclaiming_options mdbx::env::get_reclaiming ( ) const
inline

Returns current reclaiming options.

◆ get_stat() [1/2]

env::stat mdbx::env::get_stat ( ) const
inline

Returns snapshot statistics about the MDBX environment.

◆ get_stat() [2/2]

env::stat mdbx::env::get_stat ( const txn txn) const
inline

Return statistics about the MDBX environment accordingly to the specified transaction.

◆ is_empty()

bool mdbx::env::is_empty ( ) const

Checks whether the database is empty.

◆ is_pristine()

bool mdbx::env::is_pristine ( ) const

Returns true for a freshly created database, but false if at least one transaction was committed.

◆ key_max()

size_t mdbx::env::key_max ( key_mode  mode) const
inline

Returns the maximal key size in bytes for specified keys mode.

◆ key_min()

size_t mdbx::env::key_min ( key_mode  mode) const
inlinenoexcept

Returns the minimal key size in bytes for specified keys mode.

◆ max_maps()

unsigned mdbx::env::max_maps ( ) const
inline

Returns the maximum number of named databases for the environment.

◆ max_readers()

unsigned mdbx::env::max_readers ( ) const
inline

Returns the maximum number of threads/reader slots for the environment.

◆ operator bool()

MDBX_CXX14_CONSTEXPR mdbx::env::operator bool ( ) const
noexcept

◆ operator const MDBX_env *()

MDBX_CXX14_CONSTEXPR mdbx::env::operator const MDBX_env * ( ) const

◆ operator MDBX_env *()

MDBX_CXX14_CONSTEXPR mdbx::env::operator MDBX_env * ( )

◆ operator=()

env & mdbx::env::operator= ( env &&  other)
inlinenoexcept

◆ poll_sync_to_disk()

bool mdbx::env::poll_sync_to_disk ( )
inline

Performs non-blocking polling of sync-to-disk thresholds.

Returns
True if sync done or no data to sync, or false if the environment is busy by other thread or none of the thresholds are reached.

◆ prepare_read()

txn_managed mdbx::env::prepare_read ( ) const
inline

Creates but not start read transaction.

◆ remove() [1/2]

static bool mdbx::env::remove ( const ::std::string &  ,
const remove_mode  mode = just_remove 
)
static

◆ remove() [2/2]

static bool mdbx::env::remove ( const MDBX_STD_FILESYSTEM_PATH ,
const remove_mode  mode = just_remove 
)
static

Removes the environment's files in a proper and multiprocess-safe way.

◆ set_context()

env & mdbx::env::set_context ( void *  ptr)
inline

Sets the application context associated with the environment.

◆ set_geometry()

env & mdbx::env::set_geometry ( const geometry size)
inline

Set all size-related parameters of environment.

◆ set_HandleSlowReaders()

env & mdbx::env::set_HandleSlowReaders ( MDBX_hsr_func cb)
inline

Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.

Such callback will be triggered in a case where there is not enough free space in the database due to long read transaction(s) which impedes reusing the pages of an old MVCC snapshot(s).

Using this callback you can choose how to resolve the situation:

  • abort the write transaction with an error;
  • wait for the read transaction(s) to complete;
  • notify a thread performing a long-lived read transaction and wait for an effect;
  • kill the thread or whole process that performs the long-lived read transaction;
See also
long-lived-read

◆ set_sync_period() [1/2]

env & mdbx::env::set_sync_period ( double  seconds)
inline

Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.

The relative period value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with whole_fragile, lazy_weak_tail or in part half_synchronous_weak_last. Settled period don't checked asynchronously, but only by the txn_managed::commit() and env::sync_to_disk() functions. Therefore, in cases where transactions are committed infrequently and/or irregularly, polling by env::poll_sync_to_disk() may be a reasonable solution to timeout enforcement. The default is 0, than mean no any timeout checked, and no additional flush will be made.

Parameters
[in]secondsThe period in second when a synchronous flush would be made since the last unsteady commit.

◆ set_sync_period() [2/2]

env & mdbx::env::set_sync_period ( unsigned  seconds_16dot16)
inline

Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.

The relative period value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with whole_fragile, lazy_weak_tail or in part half_synchronous_weak_last. Settled period don't checked asynchronously, but only by the txn_managed::commit() and env::sync_to_disk() functions. Therefore, in cases where transactions are committed infrequently and/or irregularly, polling by env::poll_sync_to_disk() may be a reasonable solution to timeout enforcement. The default is 0, than mean no any timeout checked, and no additional flush will be made.

Parameters
[in]seconds_16dot16The period in 1/65536 of second when a synchronous flush would be made since the last unsteady commit.

◆ set_sync_threshold()

env & mdbx::env::set_sync_threshold ( size_t  bytes)
inline

Sets threshold to force flush the data buffers to disk, for non-sync durability modes.

The threshold value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with whole_fragile, lazy_weak_tail or in part half_synchronous_weak_last. The default is 0, than mean no any threshold checked, and no additional flush will be made.

◆ start_read()

txn_managed mdbx::env::start_read ( ) const
inline

Starts read (read-only) transaction.

◆ start_write()

txn_managed mdbx::env::start_write ( bool  dont_wait = false)
inline

Starts write (read-write) transaction.

◆ sync_to_disk()

bool mdbx::env::sync_to_disk ( bool  force = true,
bool  nonblock = false 
)
inline

Flush the environment data buffers.

Returns
True if sync done or no data to sync, or false if the environment is busy by other thread or none of the thresholds are reached.

◆ transaction_size_max()

size_t mdbx::env::transaction_size_max ( ) const
inline

Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.

◆ try_start_write()

txn_managed mdbx::env::try_start_write ( )
inline

Tries to start write (read-write) transaction without blocking.

◆ value_max()

size_t mdbx::env::value_max ( value_mode  mode) const
inline

Returns the maximal value size in bytes for specified values mode.

◆ value_min()

size_t mdbx::env::value_min ( value_mode  mode) const
inlinenoexcept

Returns the minimal value size in bytes for specified values mode.

Friends And Related Function Documentation

◆ operator!=

MDBX_CXX11_CONSTEXPR bool operator!= ( const env a,
const env b 
)
friend

◆ operator==

MDBX_CXX11_CONSTEXPR bool operator== ( const env a,
const env b 
)
friend

◆ txn

friend class txn
friend

Member Data Documentation

◆ handle_

MDBX_env* mdbx::env::handle_ {nullptr}
protected

The documentation for this class was generated from the following file: