02-Open_Nvram

This sample opens, inserts records, and performs transactions on a database in non-volatile memory. The application demonstrates how to store and then recover an in-memory database from a saved image in a simulated non-volatile RAM memory environment. The database is opened with a “warm start” by setting the db_params.mode_mask |= MCO_DB_OPEN_EXISTING flag. This sample must be started twice. The first time, it creates and initializes a new database, then stores an image file, nvram.img, in the transfer_money() function, then simulates a crash. On the second start, the sample allocates memory and restores the database from the image file. It then opens the database again with the MCO_DB_OPEN_EXISTING flag and recalculates the data to check the consistency of the restored database.

How to Run

See instructions here on how to build this and other samples on your development platform. Once built, the sample can be run from the \target\bin directory:

    02_open_nvram

But it is more instructive to run it in your development environment debugger, stepping through the code.

Related Topics Link IconRelated Topics