4.3. Example Configuration

So far we've been looking at things in the abstract; let's see an example of how this comes together. In this example, imagine we have a Hibernate application with the following characteristics.

Let's see a possible eviction configuration for this scenario:

<attribute name="EvictionPolicyConfig">
  <config>
         
    <attribute name="wakeUpIntervalSeconds">5</attribute>
    <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
          
    <!--  
      Default region to pick up anything we miss in the more
      specific regions below.
    -->
    <region name="/_default_">
       <attribute name="maxNodes">500</attribute>
       <attribute name="timeToLiveSeconds">300</attribute>
       <attribute name="minTimeToLiveSeconds">120</attribute>
    </region>
            
    <!--  Don't ever evict modification timestamps -->
    <region name="/TS" 
       policyClass="org.jboss.cache.eviction.NullEvictionPolicy"/>
            
    <!-- Reference data -->
    <region name="/appA/reference">
       <!-- Keep all reference data if it's being used -->
       <attribute name="maxNodes">0</attribute>
       <!-- Keep it around a long time (4 hours) -->
       <attribute name="timeToLiveSeconds">14400</attribute>
       <attribute name="minTimeToLiveSeconds">120</attribute>
    </region>
            
    <!-- Be more aggressive about queries on reference data -->
    <region name="/appA/reference/QUERY">
       <attribute name="maxNodes">200</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       <attribute name="minTimeToLiveSeconds">120</attribute>
    </region>
            
    <!-- 
       Lots of entity instances from this package, but different
       users are unlikely to share them. So, we can cache
       a lot, but evict unused ones pretty quickly.
    -->
    <region name="/appA/org/example/hibernate">
       <attribute name="maxNodes">50000</attribute>
       <attribute name="timeToLiveSeconds">1200</attribute>
       <attribute name="minTimeToLiveSeconds">120</attribute>
    </region>
            
    <!-- Clean up misc queries very promptly -->
    <region name="/appA/org/hibernate/cache/StandardQueryCache">
       <attribute name="maxNodes">200</attribute>
       <attribute name="timeToLiveSeconds">240</attribute>
       <attribute name="minTimeToLiveSeconds">120</attribute>
    </region>
            
  </config>
</attribute>

Notes on the above: