|Getting Started with Pivotal GemFire / QuickStart Examples|
Persistence creates a complete backup of the region data on disk.
At region creation time, if the disk files are already present, the data is recovered from disk and used to initialize the region.
In this example, region data is persisted to the subdirectory persistData1. You run the example twice so you can see how the persisted data is loaded into the region on the second run.
In a single session, run the example:
$ java quickstart.DataPersistence
No data is in the region on the first run, so the get operation returns null and the program reports that no entry was found. Then the program puts the entry with value, 'value1'.
When the program exits, look in the persistData1 directory. You will see the data files used for persistence.
Run the program again with the same command.
The second time, at creation, the region is initialized from disk, so the get operation returns 'value1'.
Program and cache configuration source files:
|DataPersistence.xml||Configures a region to persist its data to disk. The data files are written to the directories specified in the disk-dirs elements.|
|DataPersistence.java||Demonstrates how to create persistent data and how the region is initialized from persistent data, if it exists.|
|Persistence and Overflow|