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_EXISTINGflag. This sample must be started twice. The first time, it creates and initializes a new database, then stores an image file,nvram.img, in thetransfer_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 theMCO_DB_OPEN_EXISTINGflag and recalculates the data to check the consistency of the restored database.
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\bindirectory:02_open_nvramBut it is more instructive to run it in your development environment debugger, stepping through the code.