<?xml version="1.0" encoding="UTF-8"?>
<!--
  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.
-->

<!-- A sample GemFire declarative caching XML File -->

<cache
    xmlns="http://schema.pivotal.io/gemfire/cache"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://schema.pivotal.io/gemfire/cache http://schema.pivotal.io/gemfire/cache/cache-8.1.xsd"
    search-timeout="60" lock-lease="300" copy-on-read="false" version="8.1">

  <!-- Create a partition region -->
  <region name="myPartitionedRegion" refid="PARTITION">
    <region-attributes>
      <partition-attributes local-max-memory="32"/>

      <cache-loader>
        <class-name>com.company.app.DBLoader</class-name>
      </cache-loader>

      <eviction-attributes>
        <lru-entry-count maximum="1000" action="local-destroy"/>
      </eviction-attributes>

    </region-attributes>
  </region>
  
  <!-- Create a replicate region -->
  <region name="customers" refid="REPLICATE">
    <region-attributes>

      <entry-time-to-live>
        <expiration-attributes action="destroy" timeout="3000"/>
      </entry-time-to-live>

      <entry-idle-time>
        <expiration-attributes timeout="600"/>
      </entry-idle-time>

      <cache-loader>
        <class-name>com.company.app.DBLoader</class-name>
        <parameter name="URL">
          <string>jdbc://12.34.56.78/mydb</string>
        </parameter>
      </cache-loader>

      <eviction-attributes>
        <lru-memory-size maximum="1000" action="overflow-to-disk"> 
          <class-name>com.company.data.MySizer</class-name>
          <parameter name="name">
            <string>SuperSizer</string>
          </parameter>
        </lru-memory-size>
      </eviction-attributes>

    </region-attributes>

    <!-- Add an entry whose value is a Declarable object -->
    <entry>
      <key><string>Louise Jones</string></key>
      <value>
        <declarable>
          <class-name>com.company.app.Customer</class-name>
          <parameter name="name">
            <string>Louise Jones</string>
          </parameter>
          <parameter name="address1">
            <string>123 Main Street</string>
          </parameter>
          <parameter name="city">
            <string>New York</string>
          </parameter>
          <parameter name="state">
            <string>NY</string>
          </parameter>
          <parameter name="zip">
            <string>12345</string>
          </parameter>
        </declarable>
      </value>
    </entry>
  </region>
</cache>
