Berkeley DB Reference Guide: Simple Tutorial
Google

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

Berkeley DB Reference Guide: Simple Tutorial

Closing a database

The only other operation that we need for our simple example is closing the database. Again, this interface is accessed through a function pointer that is an element of the database handle returned by db_open.

It is necessary that the database be closed. The most important reason for this is that Berkeley DB runs on top of an underlying buffer cache. If the the database is never closed, changes that you have made to the database may never make it out to disk, because they are still in the cache. As the close function, by default, flushes the cache, closing the database will update the on-disk information.

The DB->close interface takes two arguments:

db
The database handle returned by db_open.

flags
Optional flags modifying the underlying behavior of the DB->close interface.

Here's what the code to call DB->close looks like: