Closing a Database
The only other operation that we need for our simple example is to close the database and clean up the DB handle.
It is necessary that the database be closed because Berkeley DB runs on top of an underlying buffer cache. If the modified database pages are never explicitly flushed to disk and the database is never closed, changes made to the database may never make it out to disk because they are held in the Berkeley DB cache. Because the default behavior of the close function is to flush the Berkeley DB cache, closing the database will update the on-disk information.
The DB→close interface takes two arguments:
db: The database handle returned by db_create.
flags: Optional flags that modify the underlying behavior of the ...