| 1 |
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd"> |
| 2 |
|
| 3 |
<!-- |
| 4 |
Sets the path to the directory where cache data and index files are created. |
| 5 |
|
| 6 |
If the path is a Java System Property it is replaced by its value in the running VM. Subdirectories can be specified below the property e.g. java.io.tmpdir/one |
| 7 |
|
| 8 |
The following properties are parsed and translated at runtime: |
| 9 |
user.home - User's home directory |
| 10 |
user.dir - User's current working directory |
| 11 |
java.io.tmpdir - Default temp file path |
| 12 |
|
| 13 |
e.g. java.io.tmpdir on Unix would be /tmp |
| 14 |
java.io.tmpdir/application_cache on Unix would be /tmp/application_cache |
| 15 |
--> |
| 16 |
<diskStore path="java.io.tmpdir"/> |
| 17 |
|
| 18 |
|
| 19 |
<!-- |
| 20 |
Specifies a CacheManagerEventListenerFactory which will be used to create a CacheManagerEventListener |
| 21 |
and register it with the CacheManager. |
| 22 |
|
| 23 |
A CacheManagerEventListener listens to for the following CacheManager events: |
| 24 |
- Cache added |
| 25 |
- Cache removed |
| 26 |
|
| 27 |
The attributes of cacheManagerEventListenerFactory are: |
| 28 |
- class - a fully qualified factory class name |
| 29 |
- properties - comma separated properties having meaning only to the factory. |
| 30 |
--> |
| 31 |
<!--<cacheManagerEventListenerFactory class="net.sf.ehcache.event.NullCacheManagerEventListenerFactory"--> |
| 32 |
<!--properties=""/>--> |
| 33 |
|
| 34 |
|
| 35 |
<!-- |
| 36 |
(Enable for distributed operation) |
| 37 |
|
| 38 |
Specifies a CacheManagerPeerProviderFactory which will be used to create a CacheManagerPeerProvider, which |
| 39 |
discovers other CacheManagers in the cluster. |
| 40 |
|
| 41 |
The attributes of cacheManagerPeerProviderFactory are: |
| 42 |
- class - a fully qualified factory class name |
| 43 |
- properties - comma separated properties having meaning only to the factory. |
| 44 |
|
| 45 |
Ehcache comes with a built-in RMI-based distribution system with two means of discovery of CacheManager peers |
| 46 |
participating in the cluster: |
| 47 |
- automatic, using a multicast group. This one automatically discovers peers and detects changes such as |
| 48 |
peers entering and leaving the group |
| 49 |
- manual, using manual rmiURL configuration. A hardcoded list of peers is provided at configuration time. |
| 50 |
|
| 51 |
Configuring Automatic Discovery: |
| 52 |
Automatic discovery is configured as per the following example: |
| 53 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 54 |
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446"/> |
| 55 |
|
| 56 |
Valid properties are: |
| 57 |
- peerDiscovery (mandatory) - specify "automatic" |
| 58 |
- multicastGroupAddress (mandatory) - specify a valid multicast group address |
| 59 |
- multicastGroupPort (mandatory) - specify a dedicated port for the multicast hearbeat traffic |
| 60 |
|
| 61 |
Configuring Manual Discovery: |
| 62 |
Manual discovery is configured as per the following example: |
| 63 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 64 |
properties="peerDiscovery=manual, |
| 65 |
rmiUrls=//server1:5010/sampleCache1|//server2:5010/sampleCache1|//server1:5010/sampleCache2|//server2:5010/sampleCache2"/> |
| 66 |
|
| 67 |
Valid properties are: |
| 68 |
- peerDiscovery (mandatory) - specify "manual" |
| 69 |
- rmiUrls (mandatory) - specify a pipe separated list of rmiUrls, in the form //hostname:port |
| 70 |
|
| 71 |
The hostname is the hostname of the remote CacheManager peer. The port is the listening port of the RMICacheManagerPeerListener |
| 72 |
of the remote CacheManager peer. |
| 73 |
--> |
| 74 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 75 |
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=0"/> |
| 76 |
|
| 77 |
|
| 78 |
<!-- |
| 79 |
(Enable for distributed operation) |
| 80 |
|
| 81 |
Specifies a CacheManagerPeerListenerFactory which will be used to create a CacheManagerPeerListener, which |
| 82 |
listens for messages from cache replicators participating in the cluster. |
| 83 |
|
| 84 |
The attributes of cacheManagerPeerListenerFactory are: |
| 85 |
- class - a fully qualified factory class name |
| 86 |
- properties - comma separated properties having meaning only to the factory. |
| 87 |
|
| 88 |
Ehcache comes with a built-in RMI-based distribution system. The listener component is RMICacheManagerPeerListener |
| 89 |
which is configured using RMICacheManagerPeerListenerFactory. It is configured as per the following example: |
| 90 |
|
| 91 |
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" |
| 92 |
properties="hostName=localhost, port=5011, socketTimeoutMillis=2000"/> |
| 93 |
|
| 94 |
Valid properties are: |
| 95 |
- hostName (optional) - the hostName of the host the listener is running on. Specify where the host is multihomed |
| 96 |
and you want to control the interface over which cluster messages are received. |
| 97 |
- port (mandatory) - the port the listener listens on. |
| 98 |
- socketTimeoutMillis - the number of seconds client sockets will wait when sending messages to this listener |
| 99 |
until they give up. By default this is 120s. |
| 100 |
|
| 101 |
In this example, hostName has been left blank, as has socketTimeoutMillis. They will default to |
| 102 |
the default NIC IP address and 2000ms respectively. |
| 103 |
|
| 104 |
--> |
| 105 |
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" |
| 106 |
properties="hostName=, port=, socketTimeoutMillis="/> |
| 107 |
|
| 108 |
|
| 109 |
<!--Default Cache configuration. These will applied to caches programmatically created through |
| 110 |
the CacheManager. |
| 111 |
|
| 112 |
The following attributes are required: |
| 113 |
|
| 114 |
maxElementsInMemory - Sets the maximum number of objects that will be created in memory |
| 115 |
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the |
| 116 |
element is never expired. |
| 117 |
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache |
| 118 |
has reached the maxInMemory limit. |
| 119 |
|
| 120 |
The following attributes are optional: |
| 121 |
timeToIdleSeconds - Sets the time to idle for an element before it expires. |
| 122 |
i.e. The maximum amount of time between accesses before an element expires |
| 123 |
Is only used if the element is not eternal. |
| 124 |
Optional attribute. A value of 0 means that an Element can idle for infinity. |
| 125 |
The default value is 0. |
| 126 |
timeToLiveSeconds - Sets the time to live for an element before it expires. |
| 127 |
i.e. The maximum time between creation time and when an element expires. |
| 128 |
Is only used if the element is not eternal. |
| 129 |
Optional attribute. A value of 0 means that and Element can live for infinity. |
| 130 |
The default value is 0. |
| 131 |
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine. |
| 132 |
The default value is false. |
| 133 |
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value |
| 134 |
is 120 seconds. |
| 135 |
memoryStoreEvictionPolicy - Policy would be enforced upon reaching the maxElementsInMemory limit. Default |
| 136 |
policy is Least Recently Used (specified as LRU). Other policies available - |
| 137 |
First In First Out (specified as FIFO) and Less Frequently Used |
| 138 |
(specified as LFU) |
| 139 |
cacheEventListenerClassNames - A comma separated list of CacheEventListeners. The fully qualified class name of |
| 140 |
the class which implements CacheEventListener is required. |
| 141 |
Registered listeners will be notified of cache events such as Element puts, removes and expiries |
| 142 |
and Cache status changes. The default if unspecified is an empty notifications list |
| 143 |
which does nothing. |
| 144 |
--> |
| 145 |
|
| 146 |
<defaultCache |
| 147 |
maxElementsInMemory="10" |
| 148 |
eternal="false" |
| 149 |
timeToIdleSeconds="5" |
| 150 |
timeToLiveSeconds="10" |
| 151 |
overflowToDisk="true" |
| 152 |
/> |
| 153 |
|
| 154 |
<!--Illegal name--> |
| 155 |
<cache name="default" |
| 156 |
maxElementsInMemory="1000" |
| 157 |
eternal="true" |
| 158 |
overflowToDisk="false" |
| 159 |
memoryStoreEvictionPolicy="FIFO" |
| 160 |
/> |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
</ehcache> |