LATEST VERSION: 8.2.6 - CHANGELOG
Pivotal GemFire® v8.2

Overflowing Data to Disk Example

Overflowing Data to Disk Example

Use disk with in-memory caching to overflow data to disk while your region is larger than a configured size. Overflow management is transparent to your application; the disk files are treated as an extension of the region in memory.

Disk data is maintained like in-memory data, and entry requests are automatically retrieved from the disk files as needed. This is a great alternative to eviction for applications with both a large volume of data and a high cost associated with accessing the original, outside data source.

Note: Overflow does not provide a backup of your data; it provides a disk extension to your in-memory storage space for the region. If you want to back up your data, see the Persisting Data to Disk Example.

Running the Example

In this example overflow data is written to the subdirectory overflowData1. Notice that the disk files are only there while the region is in memory. When the region is removed from memory, its overflow files are no longer needed, so they are destroyed.

Note: To run this example, you must have terminal sessions configured for the QuickStart examples, as described in Setting Up Your Environment for Running the Examples.

In a single session, run the example:

$ java -cp "$GEMFIRE/SampleCode/quickstart/classes:$GEMFIRE/lib/server-dependencies.jar" quickstart.DataOverflow

Example Source Files

Program and cache configuration source files:

Table 1. Cache configuration files, located in SampleCode//quickstart/xml
DataOverflow.xml Configures a region to overflow to disk when the region reaches a certain capacity. The data files are written to the subdirectories specified in the disk-dirs elements.
Table 2. Java program files, located in SampleCode//quickstart/quickstart
DataOverflow.java Shows cached data overflow to disk.
Related Topics
Persistence and Overflow

Related Javadocs

  • com.gemstone.gemfire.cache.EvictionAttributes
  • com.gemstone.gemfire.cache.DiskStoreFactory
  • com.gemstone.gemfire.cache.DiskStore