Berkeley DB Reference Guide: Access Methods
Google

ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++">

Berkeley DB Reference Guide: Access Methods

Closing a database

The DB->close function is the standard function for closing the database. By default, the close function also flushes all modified records from the database cache to disk.

There is one flag that you can set to customize the returned statistics:

DB_NOSYNC
Do not flush cached information to disk.

It is important to understand that flushing cached information to disk only minimizes the window of opportunity for corrupted data.

While unlikely, it is possible for database corruption to happen if a system or application crash occurs while writing data to the database. To ensure that database corruption never occurs, applications must either: use transactions and logging with automatic recovery, use logging and application-specific recovery, or edit a copy of the database, and, once all applications using the database have successfully called DB->close, use system operations (e.g., the POSIX 1003.1 rename system call) to atomically replace the original database with the updated copy.