,I;Berkeley DB Reference Guide: Simple Tutorial[P5

Berkeley DB Reference Guide: Simple Tutorial



(

Closing a database



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

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

TThe DB->close interface takes two arguments:

\

db
The database handle returned by db_open.y

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


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



MAEÿÿ