Cache Initialization File (cache.xml)

To ease the task of managing the structure of the cache, you can define the default GemFire 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 This 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 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.

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

<?xml version="1.0" encoding="UTF-8"?>
    "-//Example Systems, Inc.//Example Declarative Caching 1.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"/>