blob: ca2bb2cbeb0b3df8604fc4ee4b0f0561c044773f [file] [log] [blame]
---
title: cache.xml Quick Reference
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
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)
- [Variables in cache.xml](#topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_5DBA12F9FC08406AAD5557E13A3DEDF2)
- [Configuration Quick Reference](elements_ref.html#topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_2076DDF1F0464CF8894B42ABC32AE4CB)
## <a id="topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_A6B050113DCC4D12A6A9C0F250527AF8" class="no-quick-link"></a>Cache XML Requirements
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](http://geode.apache.org/schema/cache/cache-1.0.xsd).
- The file must include a &lt;cache&gt; schema declaration of one of the following forms:
- Server or peer cache:
``` pre
<?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:
``` pre
<?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.
## <a id="topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_5DBA12F9FC08406AAD5557E13A3DEDF2" class="no-quick-link"></a>Variables in cache.xml
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:
``` pre
<?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>
```
``` pre
gfsh>start server --name=server2 --cache-xml-file=cache.xml --J=-DPORT=30333 --J=-DMAXCNXS=77
```
## <a id="topic_7B1CABCAD056499AA57AF3CFDBF8ABE3__section_2076DDF1F0464CF8894B42ABC32AE4CB" class="no-quick-link"></a>Configuration Quick Reference
To configure cache servers, clients, and WAN topologies, see the following sections:
- Server Configuration
- [&lt;cache&gt; Element Reference](cache_xml.html#cache_xml_cache)
- [&lt;cache-server&gt;](cache_xml.html#cache-server)
- [&lt;region&gt;](cache_xml.html#region)
- [&lt;region-attributes&gt;](cache_xml.html#region-attributes)
You can set the same server configuration properties using the <span class="keyword apiname">`org.apache.geode.cache.server.CacheServer`</span> and <span class="keyword apiname">`org.apache.geode.cache.Cache`</span> interfaces. For detailed information, see the online Java API documentation.
- Client Configuration
- [&lt;client-cache&gt; Element Reference](client-cache.html#cc-client-cache)
- [&lt;pool&gt;](client-cache.html#cc-pool)
- [&lt;region&gt;](client-cache.html#cc-region)
You can set the same client configuration properties using the <span class="keyword apiname">`org.apache.geode.cache.clientClientCache`</span> and <span class="keyword apiname">`Pool`</span> interfaces. For detailed information, see the online Java API documentation.
- Multi-site (WAN) Configuration and Asynchronous Event Queue Configuration
- [&lt;gateway-sender&gt;](cache_xml.html#gateway-sender)
- [&lt;gateway-receiver&gt;](cache_xml.html#gateway-receiver)
- [&lt;async-event-queue&gt;](cache_xml.html#id_zrr_scq_rr)
The gateway sender and receiver APIs in <span class="keyword apiname">`org.apache.geode.cache.util`</span> provide corresponding getter and setter methods for these attributes.