| 1 |
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../main/config/ehcache.xsd"> |
| 2 |
|
| 3 |
|
| 4 |
<!-- |
| 5 |
Sets the path to the directory where cache data and index files are created. |
| 6 |
|
| 7 |
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 |
| 8 |
|
| 9 |
The following properties are parsed and translated at runtime: |
| 10 |
user.home - User's home directory |
| 11 |
user.dir - User's current working directory |
| 12 |
java.io.tmpdir - Default temp file path |
| 13 |
|
| 14 |
e.g. java.io.tmpdir on Unix would be /tmp |
| 15 |
java.io.tmpdir/application_cache on Unix would be /tmp/application_cache |
| 16 |
--> |
| 17 |
<diskStore path="java.io.tmpdir/one"/> |
| 18 |
|
| 19 |
|
| 20 |
<!-- |
| 21 |
Specifies a CacheManagerEventListenerFactory which will be used to create a CacheManagerEventListener |
| 22 |
and register it with the CacheManager. |
| 23 |
|
| 24 |
A CacheManagerEventListener listens to for the following CacheManager events: |
| 25 |
- Cache added |
| 26 |
- Cache removed |
| 27 |
|
| 28 |
The attributes of cacheManagerEventListenerFactory are: |
| 29 |
- class - a fully qualified factory class name |
| 30 |
- properties - comma separated properties having meaning only to the factory. |
| 31 |
--> |
| 32 |
<!--<cacheManagerEventListenerFactory class="net.sf.ehcache.event.NullCacheManagerEventListenerFactory"--> |
| 33 |
<!--properties=""/>--> |
| 34 |
<cacheManagerEventListenerFactory class="net.sf.ehcache.event.TestCacheManagerEventListenerFactory" |
| 35 |
properties="type=counting"/> |
| 36 |
|
| 37 |
|
| 38 |
<!-- |
| 39 |
(Enable for distributed operation) |
| 40 |
|
| 41 |
Specifies a CacheManagerPeerProviderFactory which will be used to create a CacheManagerPeerProvider, which |
| 42 |
discovers other CacheManagers in the cluster. |
| 43 |
|
| 44 |
The attributes of cacheManagerPeerProviderFactory are: |
| 45 |
- class - a fully qualified factory class name |
| 46 |
- properties - comma separated properties having meaning only to the factory. |
| 47 |
|
| 48 |
Ehcache comes with a built-in RMI-based distribution system with two means of discovery of CacheManager peers |
| 49 |
participating in the cluster: |
| 50 |
- automatic, using a multicast group. This one automatically discovers peers and detects changes such as |
| 51 |
peers entering and leaving the group |
| 52 |
- manual, using manual rmiURL configuration. A hardcoded list of peers is provided at configuration time. |
| 53 |
|
| 54 |
Configuring Automatic Discovery: |
| 55 |
Automatic discovery is configured as per the following example: |
| 56 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 57 |
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446"/> |
| 58 |
|
| 59 |
Valid properties are: |
| 60 |
- peerDiscovery (mandatory) - specify "automatic" |
| 61 |
- multicastGroupAddress (mandatory) - specify a valid multicast group address |
| 62 |
- multicastGroupPort (mandatory) - specify a dedicated port for the multicast hearbeat traffic |
| 63 |
|
| 64 |
Configuring Manual Discovery: |
| 65 |
Manual discovery is configured as per the following example: |
| 66 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 67 |
properties="peerDiscovery=manual, |
| 68 |
rmiUrls=//server1:5010/sampleCache1|//server2:5010/sampleCache1|//server1:5010/sampleCache2|//server2:5010/sampleCache2"/> |
| 69 |
|
| 70 |
Valid properties are: |
| 71 |
- peerDiscovery (mandatory) - specify "manual" |
| 72 |
- rmiUrls (mandatory) - specify a pipe separated list of rmiUrls, in the form //hostname:port |
| 73 |
|
| 74 |
The hostname is the hostname of the remote CacheManager peer. The port is the listening port of the RMICacheManagerPeerListener |
| 75 |
of the remote CacheManager peer. |
| 76 |
--> |
| 77 |
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" |
| 78 |
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=0"/> |
| 79 |
|
| 80 |
|
| 81 |
<!-- |
| 82 |
(Enable for distributed operation) |
| 83 |
|
| 84 |
Specifies a CacheManagerPeerListenerFactory which will be used to create a CacheManagerPeerListener, which |
| 85 |
listens for messages from cache replicators participating in the cluster. |
| 86 |
|
| 87 |
The attributes of cacheManagerPeerListenerFactory are: |
| 88 |
- class - a fully qualified factory class name |
| 89 |
- properties - comma separated properties having meaning only to the factory. |
| 90 |
|
| 91 |
Ehcache comes with a built-in RMI-based distribution system. The listener component is RMICacheManagerPeerListener |
| 92 |
which is configured using RMICacheManagerPeerListenerFactory. It is configured as per the following example: |
| 93 |
|
| 94 |
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" |
| 95 |
properties="hostName=localhost, port=5011, socketTimeoutMillis=2000"/> |
| 96 |
|
| 97 |
Valid properties are: |
| 98 |
- hostName (optional) - the hostName of the host the listener is running on. Specify where the host is multihomed |
| 99 |
and you want to control the interface over which cluster messages are received. |
| 100 |
- port (mandatory) - the port the listener listens on. |
| 101 |
- socketTimeoutMillis - the number of seconds client sockets will wait when sending messages to this listener |
| 102 |
until they give up. By default this is 120s. |
| 103 |
|
| 104 |
In this example, hostName has been left blank, as has socketTimeoutMillis. They will default to |
| 105 |
the default NIC IP address and 2000ms respectively. |
| 106 |
|
| 107 |
--> |
| 108 |
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" |
| 109 |
properties="hostName=, port=5011, socketTimeoutMillis="/> |
| 110 |
|
| 111 |
|
| 112 |
<!--Default Cache configuration. These will applied to caches programmatically created through |
| 113 |
the CacheManager. |
| 114 |
|
| 115 |
The following attributes are required: |
| 116 |
|
| 117 |
maxElementsInMemory - Sets the maximum number of objects that will be created in memory |
| 118 |
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the |
| 119 |
element is never expired. |
| 120 |
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache |
| 121 |
has reached the maxInMemory limit. |
| 122 |
|
| 123 |
The following attributes are optional: |
| 124 |
timeToIdleSeconds - Sets the time to idle for an element before it expires. |
| 125 |
i.e. The maximum amount of time between accesses before an element expires |
| 126 |
Is only used if the element is not eternal. |
| 127 |
Optional attribute. A value of 0 means that an Element can idle for infinity. |
| 128 |
The default value is 0. |
| 129 |
timeToLiveSeconds - Sets the time to live for an element before it expires. |
| 130 |
i.e. The maximum time between creation time and when an element expires. |
| 131 |
Is only used if the element is not eternal. |
| 132 |
Optional attribute. A value of 0 means that and Element can live for infinity. |
| 133 |
The default value is 0. |
| 134 |
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine. |
| 135 |
The default value is false. |
| 136 |
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value |
| 137 |
is 120 seconds. |
| 138 |
memoryStoreEvictionPolicy - Policy would be enforced upon reaching the maxElementsInMemory limit. Default |
| 139 |
policy is Least Recently Used (specified as LRU). Other policies available - |
| 140 |
First In First Out (specified as FIFO) and Less Frequently Used |
| 141 |
(specified as LFU) |
| 142 |
--> |
| 143 |
|
| 144 |
<defaultCache |
| 145 |
maxElementsInMemory="10" |
| 146 |
eternal="false" |
| 147 |
timeToIdleSeconds="100" |
| 148 |
timeToLiveSeconds="100" |
| 149 |
overflowToDisk="true"> |
| 150 |
</defaultCache> |
| 151 |
|
| 152 |
|
| 153 |
<!--Predefined caches. Add your cache configuration settings here. |
| 154 |
If you do not have a configuration for your cache a WARNING will be issued when the |
| 155 |
CacheManager starts |
| 156 |
|
| 157 |
The following attributes are required for defaultCache: |
| 158 |
|
| 159 |
name - Sets the name of the cache. This is used to identify the cache. |
| 160 |
It must be unique. |
| 161 |
maxElementsInMemory - Sets the maximum number of objects that will be created in memory |
| 162 |
eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the |
| 163 |
element is never expired. |
| 164 |
overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache |
| 165 |
has reached the maxInMemory limit. |
| 166 |
|
| 167 |
The following attributes are optional: |
| 168 |
timeToIdleSeconds - Sets the time to idle for an element before it expires. |
| 169 |
i.e. The maximum amount of time between accesses before an element expires |
| 170 |
Is only used if the element is not eternal. |
| 171 |
Optional attribute. A value of 0 means that an Element can idle for infinity. |
| 172 |
The default value is 0. |
| 173 |
timeToLiveSeconds - Sets the time to live for an element before it expires. |
| 174 |
i.e. The maximum time between creation time and when an element expires. |
| 175 |
Is only used if the element is not eternal. |
| 176 |
Optional attribute. A value of 0 means that and Element can live for infinity. |
| 177 |
The default value is 0. |
| 178 |
diskPersistent - Whether the disk store persists between restarts of the Virtual Machine. |
| 179 |
The default value is false. |
| 180 |
diskExpiryThreadIntervalSeconds- The number of seconds between runs of the disk expiry thread. The default value |
| 181 |
is 120 seconds. |
| 182 |
memoryStoreEvictionPolicy - Policy would be enforced upon reaching the maxElementsInMemory limit. Default |
| 183 |
policy is Least Recently Used (specified as LRU). Other policies available - |
| 184 |
First In First Out (specified as FIFO) and Less Frequently Used |
| 185 |
(specified as LFU) |
| 186 |
--> |
| 187 |
|
| 188 |
|
| 189 |
<!-- Sample cache named sampleCache1 --> |
| 190 |
<cache name="sampleCache1" |
| 191 |
maxElementsInMemory="10" |
| 192 |
eternal="false" |
| 193 |
timeToIdleSeconds="100" |
| 194 |
timeToLiveSeconds="100" |
| 195 |
overflowToDisk="true" |
| 196 |
memoryStoreEvictionPolicy="LRU" |
| 197 |
diskExpiryThreadIntervalSeconds="1000" |
| 198 |
> |
| 199 |
<cacheEventListenerFactory class="net.sf.ehcache.event.CountingCacheEventListenerFactory"/> |
| 200 |
</cache> |
| 201 |
|
| 202 |
<!-- Sample cache named sampleCache2. --> |
| 203 |
<cache name="sampleCache2" |
| 204 |
maxElementsInMemory="10" |
| 205 |
eternal="false" |
| 206 |
timeToIdleSeconds="100" |
| 207 |
timeToLiveSeconds="100" |
| 208 |
overflowToDisk="false"> |
| 209 |
|
| 210 |
</cache> |
| 211 |
|
| 212 |
|
| 213 |
<!-- Sample cache named sampleCache3. It is set for synchronous replication. --> |
| 214 |
<cache name="sampleCache3" |
| 215 |
maxElementsInMemory="10" |
| 216 |
eternal="true" |
| 217 |
overflowToDisk="true"> |
| 218 |
|
| 219 |
</cache> |
| 220 |
|
| 221 |
<!-- Sample cache named sampleCache4. All missing RMICacheReplicatorFactory properties default to true --> |
| 222 |
<cache name="sampleCache4" |
| 223 |
maxElementsInMemory="10" |
| 224 |
eternal="true" |
| 225 |
overflowToDisk="false" |
| 226 |
memoryStoreEvictionPolicy="LFU"> |
| 227 |
|
| 228 |
</cache> |
| 229 |
|
| 230 |
<!-- Sample cache names sampleCache5. The missing replicatePuts will default to true --> |
| 231 |
<cache name="sampleCache5" |
| 232 |
maxElementsInMemory="10" |
| 233 |
eternal="false" |
| 234 |
timeToLiveSeconds="100" |
| 235 |
overflowToDisk="false"> |
| 236 |
|
| 237 |
</cache> |
| 238 |
|
| 239 |
<cache name="sampleCache6" |
| 240 |
maxElementsInMemory="10" |
| 241 |
eternal="false" |
| 242 |
timeToLiveSeconds="100" |
| 243 |
overflowToDisk="false"> |
| 244 |
|
| 245 |
</cache> |
| 246 |
|
| 247 |
<cache name="sampleCache7" |
| 248 |
maxElementsInMemory="10" |
| 249 |
eternal="false" |
| 250 |
timeToLiveSeconds="100" |
| 251 |
overflowToDisk="false"> |
| 252 |
|
| 253 |
</cache> |
| 254 |
|
| 255 |
|
| 256 |
<cache name="sampleCache8" |
| 257 |
maxElementsInMemory="10" |
| 258 |
eternal="false" |
| 259 |
timeToLiveSeconds="100" |
| 260 |
overflowToDisk="false"> |
| 261 |
|
| 262 |
</cache> |
| 263 |
|
| 264 |
|
| 265 |
<cache name="sampleCache9" |
| 266 |
maxElementsInMemory="10" |
| 267 |
eternal="false" |
| 268 |
timeToLiveSeconds="100" |
| 269 |
overflowToDisk="false"> |
| 270 |
|
| 271 |
</cache> |
| 272 |
|
| 273 |
|
| 274 |
<cache name="sampleCache10" |
| 275 |
maxElementsInMemory="10" |
| 276 |
eternal="false" |
| 277 |
timeToLiveSeconds="100" |
| 278 |
overflowToDisk="false"> |
| 279 |
|
| 280 |
</cache> |
| 281 |
|
| 282 |
</ehcache> |