title: cache.xml Quick Reference sidebar_label: cache.xml Quick Reference sidebar_position: 1

This section documents cache.xml file requirements and variables. It also points you to specific element sections for server, client, and WAN configuration.

Cache XML Requirements {#topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_A6B050113DCC4D12A6A9C0F250527AF8}

The cache.xml file has these requirements:

  • The contents must conform to the XML schema definition provided in cache-1.0.xsd. The schema definition file is available at http://geode.apache.org/schema/cache/cache-1.0.xsd.

  • The file must include a <cache> schema declaration of one of the following forms:

    • Server or peer cache:

      <?xml version="1.0" encoding="UTF-8"?>
      <cache
          xmlns="http://geode.apache.org/schema/cache"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
          version="1.0">
      ...
      </cache>
      
    • Client cache:

      <?xml version="1.0" encoding="UTF-8"?>
      <client-cache
          xmlns="http://geode.apache.org/schema/cache"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
          version="1.0">
      ...
      </client-cache>
      
  • Any class name specified in the file must have a public zero-argument constructor and must implement the org.apache.geode.cache.Declarable interface. Parameters declared in the XML for the class are passed to the class init method.

Variables in cache.xml {#topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_5DBA12F9FC08406AAD5557E13A3DEDF2}

You can use variables in the cache.xml to customize your settings without modifying the XML file.

Set your variables in Java system properties when you start your cache server or application process.

Example cache.xml with variables and the gfsh start server command that sets the variables:

<?xml version="1.0" encoding="UTF-8"?>
<cache
    xmlns="http://geode.apache.org/schema/cache"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
    version="1.0">
  <cache-server port="${PORT}" max-connections="${MAXCNXS}"/>
  <region name="root">
    <region-attributes refid="REPLICATE"/>
  </region>
</cache>
gfsh>start server --name=server2 --cache-xml-file=cache.xml --J=-DPORT=30333 --J=-DMAXCNXS=77

Configuration Quick Reference {#topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_2076DDF1F0464CF8894B42ABC32AE4CB}

To configure cache servers, clients, and WAN topologies, see the following sections: