<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2010, Sebastian Sdorra
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    3. Neither the name of SCM-Manager; nor the names of its
       contributors may be used to endorse or promote products derived from this
       software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    http://bitbucket.org/sdorra/scm-manager


-->

<!--
    Document   : ehcache.xml
    Created on : October 14, 2010, 6:54 AM
    Author     : sdorra
    Description:
        Purpose of the document follows.
-->

<ehcache xmlns="http://ehcache.org/ehcache.xsd">


  <!--
    Sets the path to the directory where cache .data files are created.

    If the path is a Java System Property it is replaced by
    its value in the running VM.

    The following properties are translated:
    user.home - User's home directory
    user.dir - User's current working directory
    java.io.tmpdir - Default temp file path
  -->
  
  <diskStore path="java.io.tmpdir"/>


  <!--
    Default Cache configuration. These will applied to caches programmatically created through
    the CacheManager.

    The following attributes are required:

    maxElementsInMemory            - Sets the maximum number of objects that will be created in memory
    eternal                        - Sets whether elements are eternal. If eternal,  timeouts are ignored and the
                                     element is never expired.
    overflowToDisk                 - Sets whether elements can overflow to disk when the in-memory cache
                                     has reached the maxInMemory limit.

    The following attributes are optional:
    timeToIdleSeconds              - Sets the time to idle for an element before it expires.
                                     i.e. The maximum amount of time between accesses before an element expires
                                     Is only used if the element is not eternal.
                                     Optional attribute. A value of 0 means that an Element can idle for infinity.
                                     The default value is 0.
    timeToLiveSeconds              - Sets the time to live for an element before it expires.
                                     i.e. The maximum time between creation time and when an element expires.
                                     Is only used if the element is not eternal.
                                     Optional attribute. A value of 0 means that and Element can live for infinity.
                                     The default value is 0.
    diskPersistent                 - Whether the disk store persists between restarts of the Virtual Machine.
                                     The default value is false.
    diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value
                                     is 120 seconds.
  -->

  <defaultCache
        maxElementsInMemory="20000"
        eternal="false"
        overflowToDisk="false"
        timeToIdleSeconds="1200"
        timeToLiveSeconds="2400"
        diskPersistent="false"
        diskExpiryThreadIntervalSeconds="2400"
  />

  <cache
        name="sonia.cache.plugin-backend"
        maxElementsInMemory="20000"
        eternal="false"
        overflowToDisk="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="3600"
        diskPersistent="false"
  />
  
  <cache
        name="sonia.cache.plugin-detail"
        maxElementsInMemory="20000"
        eternal="false"
        overflowToDisk="false"
        timeToIdleSeconds="1800"
        timeToLiveSeconds="3600"
        diskPersistent="false"
  />
  
  <!-- shiro -->
  
  <!-- We want eternal="true" and no timeToIdle or timeToLive settings because Shiro manages session
       expirations explicitly.  If we set it to false and then set corresponding timeToIdle and timeToLive properties,
       ehcache would evict sessions without Shiro's knowledge, which would cause many problems
      (e.g. "My Shiro session timeout is 30 minutes - why isn't a session available after 2 minutes?"
             Answer - ehcache expired it due to the timeToIdle property set to 120 seconds.)

      diskPersistent=true since we want an enterprise session management feature - ability to use sessions after
      even after a JVM restart.  -->
  <cache name="shiro-activeSessionCache"
         maxElementsInMemory="10000"
         overflowToDisk="true"
         eternal="true"
         timeToLiveSeconds="0"
         timeToIdleSeconds="0"
         diskPersistent="true"
         diskExpiryThreadIntervalSeconds="600"
  />

  <cache name="org.apache.shiro.realm.text.PropertiesRealm-0-accounts"
         maxElementsInMemory="1000"
         eternal="true"
         overflowToDisk="true"
  />

</ehcache>
