+I:Berkeley DB Reference Guide: Access Methods[P4

Berkeley DB Reference Guide: Access Methods



1

Flushing the database cache



bThe DB->sync function is the standard function for flushing5all modified records from the database cache to disk.

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

EWhile unlikely, it is possible for database corruption to happen if aIsystem or application crash occurs while writing data to the database. ToGensure that database corruption never occurs, applications must either:Euse transactions and logging with automatic recovery, use logging andHapplication-specific recovery, or edit a copy of the database, and, once<all applications using the database have successfully calledgDB->close, use system operations (e.g., the POSIX 1003.1 renameIsystem call) to atomically replace the original database with the updatedcopy.

HAFÿÿ