Pivotal GemFire® Native Client v9.0

Cache Initialization File (cache.xml)

To ease the task of managing the structure of the cache, you can define the default Geode cache structure in an XML-based initialization file.

Cache Initialization File Basics

The contents of the cache initialization file are used to populate or update a cache.

This occurs when a cache server starts up, when a client application explicitly creates its cache, or when a client explicitly loads a new structure into an existing cache.

The initialization file can have any name, but is generally referred to as cache.xml. Both client applications and cache servers can use an optional cache.xml file to ease the initialization process.

File Contents

The contents of a declarative XML file correspond to APIs declared in the Cache.hpp and Region.hpp header files. The cache initialization file allows you to accomplish declaratively many of the cache management activities that you can program through the API.

  • The contents of the cache initialization file must conform to the XML definition in product-dir/dtd/gfcpp-cache8000.dtd. The DTD file identifies the valid element tags that may be present in your XML file, the attributes that correspond to each element, and the valid values for the elements and attributes.
  • The name of the declarative XML file is specified when establishing a connection to the distributed system. You can define it by setting the cache-xml-file configuration attribute in the file for the native client. For details about the file, see Setting System and Cache Properties.

Example cache.xml File

An example cache.xml file shows cache and region initialization for a client, presenting a subset of the possible data configurations.

Specific information about cache and region attributes is in Region Attributes. Also check the API documentation for Cache and RegionAttributes at

For information on using a cache with a server pool, see Using Connection Pools. The example below shows a cache.xml file that creates two regions.

  • Region region1 is defined with a full set of region attributes and application plug-ins. The region’s entries have RegionTimeToLive and RegionIdleTimeout expiration attributes set, as detailed in Specifying Expiration Attributes.
  • Region region2 uses mostly default values.
<?xml version="1.0" encoding="UTF-8"?>
    "-//Example Systems, Inc.//Example Declarative Caching 8.0//EN"
<!-- Sample cache.xml file -->
<!-- Example Declarative Cache Initialization with cache.xml -->
    <pool name="examplePool" subscription-enabled="true">
        <server host="localhost" port="24680" />
    <region name="root1" refid="CACHING_PROXY">
        <region-attributes pool-name="examplePool"
                <expiration-attributes timeout="20" action="destroy"/>
                <expiration-attributes timeout="10" action="invalidate"/>
                <expiration-attributes timeout="5" action="local-destroy"/>
                <expiration-attributes timeout="10" action="local-invalidate"/>