Debian Codegraph @

src/main/config/ehcache.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4 CacheManager Configuration
5 ==========================
6 An ehcache.xml corresponds to a single CacheManager.
7
8 See instructions below or the ehcache schema (ehcache.xsd) on how to configure.
9
10 System property tokens can be specified in this file which are replaced when the configuration
11 is loaded. For example multicastGroupPort=${multicastGroupPort} can be replaced with the
12 System property either from an environment variable or a system property specified with a
13 command line switch such as -DmulticastGroupPort=4446. Another example, useful for Terracotta
14 server based deployments is <terracottaConfig url="${serverAndPort}"/ and specify a command line
15 switch of -Dserver36:9510
16
17 The attributes of <ehcache> are:
18 * name - an optional name for the CacheManager. The name is optional and primarily used
19 for documentation or to distinguish Terracotta clustered cache state. With Terracotta
20 clustered caches, a combination of CacheManager name and cache name uniquely identify a
21 particular cache store in the Terracotta clustered memory.
22 * updateCheck - an optional boolean flag specifying whether this CacheManager should check
23 for new versions of Ehcache over the Internet. If not specified, updateCheck="true".
24 * dynamicConfig - an optional setting that can be used to disable dynamic configuration of caches
25 associated with this CacheManager. By default this is set to true - i.e. dynamic configuration
26 is enabled. Dynamically configurable caches can have their TTI, TTL and maximum disk and
27 in-memory capacity changed at runtime through the cache's configuration object.
28 * monitoring - an optional setting that determines whether the CacheManager should
29 automatically register the SampledCacheMBean with the system MBean server.
30
31 Currently, this monitoring is only useful when using Terracotta clustering and using the
32 Terracotta Developer Console. With the "autodetect" value, the presence of Terracotta clustering
33 will be detected and monitoring, via the Developer Console, will be enabled. Other allowed values
34 are "on" and "off". The default is "autodetect". This setting does not perform any function when
35 used with JMX monitors.
36
37 * maxBytesLocalHeap - optional setting that constraints the memory usage of the Caches managed by the CacheManager
38 to use at most the specified number of bytes of the local VM's heap.
39 * maxBytesLocalOffHeap - optional setting that constraints the offHeap usage of the Caches managed by the CacheManager
40 to use at most the specified number of bytes of the local VM's offHeap memory.
41 * maxBytesLocalDisk - optional setting that constraints the disk usage of the Caches managed by the CacheManager
42 to use at most the specified number of bytes of the local disk.
43
44 These settings let you define "resource pools", caches will share. For instance setting maxBytesLocalHeap to 100M, will result in
45 all caches sharing 100 MegaBytes of ram. The CacheManager will balance these 100 MB across all caches based on their respective usage
46 patterns. You can allocate a precise amount of bytes to a particular cache by setting the appropriate maxBytes* attribute for that cache.
47 That amount will be subtracted from the CacheManager pools, so that if a cache a specified 30M requirement, the other caches will share
48 the remaining 70M.
49
50 Also, specifying a maxBytesLocalOffHeap at the CacheManager level will result in overflowToOffHeap to be true by default. If you don't want
51 a specific cache to overflow to off heap, you'll have to set overflowToOffHeap="false" explicitly
52
53 Here is an example of CacheManager level resource tuning, which will use up to 400M of heap and 2G of offHeap:
54
55 <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56 xsi:noNamespaceSchemaLocation="ehcache.xsd"
57 updateCheck="true" monitoring="autodetect"
58 dynamicConfig="true" maxBytesLocalHeap="400M" maxBytesLocalOffHeap="2G">
59
60 -->
61 <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
62 xsi:noNamespaceSchemaLocation="ehcache.xsd"
63 updateCheck="true" monitoring="autodetect"
64 dynamicConfig="true">
65
66 <!--
67 Management Rest Service configuration
68 =====================================
69
70 The managementRESTService element is optional. By default the REST service that exposes monitoring and
71 management features for the caches within the cache manager is disabled. Enabling this feature will
72 affect cache performance.
73
74 To meaningfully use this REST monitoring feature, you should also set statistics="true" on caches.
75
76 The 'bind' attribute defaults to "0.0.0.0:9888" and sets the IP Address and Port to bind the web service
77 to. "0.0.0.0" binds to all local addresses / network interfaces.
78
79 If you provide the 'securityServiceLocation' attribute, this will also enable authentication and other
80 security measures on the REST service - which are only available for the enterprise-edition of the
81 service. The location should be the URL to the Terracotta Management Server that is being used to
82 manage the ehcache instance. Enabling security requires that the management REST service be provided with
83 a terracotta keychain in the default location ${user.home}/.tc/mgmt/keychain or as defined by the system property
84 com.tc.management.keychain.file. The keychain is expected to hold a secret shared by the management client
85 and keyed with this REST service's URI.
86
87 Related to the the enterprise-edition security setup is the 'securityServiceTimeout' attribute. Setting this
88 value will allow adjustment of the connection timeout to the security service location. The default value is
89 5000 millis.
90
91 If the 'sslEnabled' attribute is set to true, this will enable a non-blocking ssl connection to the management
92 REST service. Turning this ssl connection on requires an identity store be provided at the default location
93 ${user.home}/.tc/mgmt/keystore and that the JKS passphrase be included in the REST service keychain, keyed with
94 the identity store file URI, or that the keystore and passphrase be identified with the ssl system properties
95 javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword.
96
97 The 'needClientAuth' attribute requires ssl client certificate authorization if the 'sslEnabled' attribute has been
98 set to true. Otherwise, it will be ignored. Setting this attribute to true will require that the client's
99 identity is imported as trusted into a truststore which is provided in the default location
100 ${user.home}/.tc/mgmt/keystore and that the JKS passphrase be included in the REST service keychain, keyed with
101 the trust store file URI, or that the truststore and passphrase be identified with the ssl system properties
102 javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword.
103
104 Finally, several attributes exist to configure sampling history.
105
106 - 'sampleHistorySize' allows the configuration of how many statistical samples will be kept in memory for
107 each cache. The default value is set to 30.
108 - 'sampleIntervalSeconds' allows the configuration of how often cache statistics will be obtained in seconds.
109 The default value is set to 1 second.
110 - 'sampleSearchIntervalSeconds' allows the configuration of how often cache seach statistics will be obtained in
111 seconds. The default value is set to 10 seconds.
112
113 examples:
114
115 <managementRESTService enabled="true" bind="0.0.0.0:9888" />
116
117 <managementRESTService enabled="true" securityServiceLocation="http://localhost:9889/tmc/api/assertIdentity" />
118
119 -->
120
121 <!--
122 DiskStore configuration
123 =======================
124
125 The diskStore element is optional. To turn off disk store path creation, comment out the diskStore
126 element below.
127
128 Configure it if you have disk persistence enabled for any cache or if you use
129 unclustered indexed search.
130
131 If it is not configured, and a cache is created which requires a disk store, a warning will be
132 issued and java.io.tmpdir will automatically be used.
133
134 diskStore has only one attribute - "path". It is the path to the directory where
135 any required disk files will be created.
136
137 If the path is one of the following Java System Property it is replaced by its value in the
138 running VM. For backward compatibility these should be specified without being enclosed in the ${token}
139 replacement syntax.
140
141 The following properties are translated:
142 * user.home - User's home directory
143 * user.dir - User's current working directory
144 * java.io.tmpdir - Default temp file path
145 * ehcache.disk.store.dir - A system property you would normally specify on the command line
146 e.g. java -Dehcache.disk.store.dir=/u01/myapp/diskdir ...
147
148 Subdirectories can be specified below the property e.g. java.io.tmpdir/one
149
150 -->
151 <diskStore path="java.io.tmpdir"/>
152
153 <!--
154 TransactionManagerLookup configuration
155 ======================================
156 This class is used by ehcache to lookup the JTA TransactionManager use in the application
157 using an XA enabled ehcache. If no class is specified then DefaultTransactionManagerLookup
158 will find the TransactionManager in the following order
159
160 *GenericJNDI (i.e. jboss, where the property jndiName controls the name of the
161 TransactionManager object to look up)
162 *Bitronix
163 *Atomikos
164
165 You can provide you own lookup class that implements the
166 net.sf.ehcache.transaction.manager.TransactionManagerLookup interface.
167 -->
168
169 <transactionManagerLookup class="net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup"
170 properties="jndiName=java:/TransactionManager" propertySeparator=";"/>
171
172
173 <!--
174 CacheManagerEventListener
175 =========================
176 Specifies a CacheManagerEventListenerFactory which is notified when Caches are added
177 or removed from the CacheManager.
178
179 The attributes of CacheManagerEventListenerFactory are:
180 * class - a fully qualified factory class name
181 * properties - comma separated properties having meaning only to the factory.
182
183 Sets the fully qualified class name to be registered as the CacheManager event listener.
184
185 The events include:
186 * adding a Cache
187 * removing a Cache
188
189 Callbacks to listener methods are synchronous and unsynchronized. It is the responsibility
190 of the implementer to safely handle the potential performance and thread safety issues
191 depending on what their listener is doing.
192
193 If no class is specified, no listener is created. There is no default.
194 -->
195 <cacheManagerEventListenerFactory class="" properties=""/>
196
197
198 <!--
199 CacheManagerPeerProvider
200 ========================
201 (For distributed operation)
202
203 Specifies a CacheManagerPeerProviderFactory which will be used to create a
204 CacheManagerPeerProvider, which discovers other CacheManagers in the cluster.
205
206 One or more providers can be configured. The first one in the ehcache.xml is the default, which is used
207 for replication and bootstrapping.
208
209 The attributes of cacheManagerPeerProviderFactory are:
210 * class - a fully qualified factory class name
211 * properties - comma separated properties having meaning only to the factory.
212
213 Providers are available for RMI, JGroups and JMS as shown following.
214
215 RMICacheManagerPeerProvider
216 +++++++++++++++++++++++++++
217
218 Ehcache comes with a built-in RMI-based distribution system with two means of discovery of
219 CacheManager peers participating in the cluster:
220 * automatic, using a multicast group. This one automatically discovers peers and detects
221 changes such as peers entering and leaving the group
222 * manual, using manual rmiURL configuration. A hardcoded list of peers is provided at
223 configuration time.
224
225 Configuring Automatic Discovery:
226 Automatic discovery is configured as per the following example:
227 <cacheManagerPeerProviderFactory
228 class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
229 properties="hostName=fully_qualified_hostname_or_ip,
230 peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
231 multicastGroupPort=4446, timeToLive=32"/>
232
233 Valid properties are:
234 * peerDiscovery (mandatory) - specify "automatic"
235 * multicastGroupAddress (mandatory) - specify a valid multicast group address
236 * multicastGroupPort (mandatory) - specify a dedicated port for the multicast heartbeat
237 traffic
238 * timeToLive - specify a value between 0 and 255 which determines how far the packets will
239 propagate.
240
241 By convention, the restrictions are:
242 0 - the same host
243 1 - the same subnet
244 32 - the same site
245 64 - the same region
246 128 - the same continent
247 255 - unrestricted
248
249 * hostName - the hostname or IP of the interface to be used for sending and receiving multicast
250 packets (relevant to multi-homed hosts only)
251
252 Configuring Manual Discovery:
253 Manual discovery requires a unique configuration per host. It is contains a list of rmiURLs for
254 the peers, other than itself. So, if we have server1, server2 and server3 the configuration will
255 be:
256
257 In server1's configuration:
258 <cacheManagerPeerProviderFactory class=
259 "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
260 properties="peerDiscovery=manual,
261 rmiUrls=//server2:40000/sampleCache1|//server3:40000/sampleCache1
262 | //server2:40000/sampleCache2|//server3:40000/sampleCache2"
263 propertySeparator="," />
264
265 In server2's configuration:
266 <cacheManagerPeerProviderFactory class=
267 "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
268 properties="peerDiscovery=manual,
269 rmiUrls=//server1:40000/sampleCache1|//server3:40000/sampleCache1
270 | //server1:40000/sampleCache2|//server3:40000/sampleCache2"
271 propertySeparator="," />
272
273 In server3's configuration:
274 <cacheManagerPeerProviderFactory class=
275 "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
276 properties="peerDiscovery=manual,
277 rmiUrls=//server1:40000/sampleCache1|//server2:40000/sampleCache1
278 | //server1:40000/sampleCache2|//server2:40000/sampleCache2"
279 propertySeparator="," />
280
281
282 Valid properties are:
283 * peerDiscovery (mandatory) - specify "manual"
284 * rmiUrls (mandatory) - specify a pipe separated list of rmiUrls, in the form
285 //hostname:port
286 * hostname (optional) - the hostname is the hostname of the remote CacheManager peer. The port is the listening
287 port of the RMICacheManagerPeerListener of the remote CacheManager peer.
288
289 JGroupsCacheManagerPeerProvider
290 +++++++++++++++++++++++++++++++
291 <cacheManagerPeerProviderFactory
292 class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
293 properties="channel=ehcache^connect=UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;
294 mcast_send_buf_size=150000;mcast_recv_buf_size=80000):
295 PING(timeout=2000;num_initial_members=6):
296 MERGE2(min_interval=5000;max_interval=10000):
297 FD_SOCK:VERIFY_SUSPECT(timeout=1500):
298 pbcast.NAKACK(gc_lag=10;retransmit_timeout=3000):
299 UNICAST(timeout=5000):
300 pbcast.STABLE(desired_avg_gossip=20000):
301 FRAG:
302 pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=false)"
303 propertySeparator="^"
304 />
305 JGroups configuration is done by providing a connect string using connect= as in the above example which uses
306 multicast, or since version 1.4, a file= to specify the location of a JGroups configuration file.
307
308 If neither a connect or file property is specified, the default JGroups JChannel will be used.
309
310 Multiple JGroups clusters may be run on the same network by specifying a different CacheManager name. The name
311 is used as the cluster name.
312
313 Since version 1.4 you can specify a channelName to avoid conflicts.
314
315
316 JMSCacheManagerPeerProviderFactory
317 ++++++++++++++++++++++++++++++++++
318 <cacheManagerPeerProviderFactory
319 class="net.sf.ehcache.distribution.jms.JMSCacheManagerPeerProviderFactory"
320 properties="..."
321 propertySeparator=","
322 />
323
324 The JMS PeerProviderFactory uses JNDI to maintain message queue independence. Refer to the manual for full configuration
325 examples using ActiveMQ and Open Message Queue.
326
327 Valid properties are:
328 * initialContextFactoryName (mandatory) - the name of the factory used to create the message queue initial context.
329 * providerURL (mandatory) - the JNDI configuration information for the service provider to use.
330 * topicConnectionFactoryBindingName (mandatory) - the JNDI binding name for the TopicConnectionFactory
331 * topicBindingName (mandatory) - the JNDI binding name for the topic name
332 * getQueueBindingName (mandatory only if using jmsCacheLoader) - the JNDI binding name for the queue name
333 * securityPrincipalName - the JNDI java.naming.security.principal
334 * securityCredentials - the JNDI java.naming.security.credentials
335 * urlPkgPrefixes - the JNDI java.naming.factory.url.pkgs
336 * userName - the user name to use when creating the TopicConnection to the Message Queue
337 * password - the password to use when creating the TopicConnection to the Message Queue
338 * acknowledgementMode - the JMS Acknowledgement mode for both publisher and subscriber. The available choices are
339 AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE and SESSION_TRANSACTED. The default is AUTO_ACKNOWLEDGE.
340 -->
341 <cacheManagerPeerProviderFactory
342 class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
343 properties="peerDiscovery=automatic,
344 multicastGroupAddress=230.0.0.1,
345 multicastGroupPort=4446, timeToLive=1"
346 propertySeparator=","
347 />
348
349
350 <!--
351 CacheManagerPeerListener
352 ========================
353 (Enable for distributed operation)
354
355 Specifies a CacheManagerPeerListenerFactory which will be used to create a
356 CacheManagerPeerListener, which listens for messages from cache replicators participating in the cluster.
357
358 The attributes of cacheManagerPeerListenerFactory are:
359 class - a fully qualified factory class name
360 properties - comma separated properties having meaning only to the factory.
361
362 Ehcache comes with a built-in RMI-based distribution system. The listener component is
363 RMICacheManagerPeerListener which is configured using
364 RMICacheManagerPeerListenerFactory. It is configured as per the following example:
365
366 <cacheManagerPeerListenerFactory
367 class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
368 properties="hostName=fully_qualified_hostname_or_ip,
369 port=40001,
370 remoteObjectPort=40002,
371 socketTimeoutMillis=120000"
372 propertySeparator="," />
373
374 All properties are optional. They are:
375 * hostName - the hostName of the host the listener is running on. Specify
376 where the host is multihomed and you want to control the interface over which cluster
377 messages are received. Defaults to the host name of the default interface if not
378 specified.
379 * port - the port the RMI Registry listener listens on. This defaults to a free port if not specified.
380 * remoteObjectPort - the port number on which the remote objects bound in the registry receive calls.
381 This defaults to a free port if not specified.
382 * socketTimeoutMillis - the number of ms client sockets will stay open when sending
383 messages to the listener. This should be long enough for the slowest message.
384 If not specified it defaults to 120000ms.
385
386 -->
387 <cacheManagerPeerListenerFactory
388 class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>
389
390 <!--
391 TerracottaConfig
392 ========================
393 (Enable for Terracotta clustered operation)
394
395 Note: You need to install and run one or more Terracotta servers to use Terracotta clustering.
396 See http://www.terracotta.org/web/display/orgsite/Download.
397
398 Specifies a TerracottaConfig which will be used to configure the Terracotta
399 runtime for this CacheManager.
400
401 Configuration can be specified in two main ways: by reference to a source of
402 configuration or by use of an embedded Terracotta configuration file.
403
404 To specify a reference to a source (or sources) of configuration, use the url
405 attribute. The url attribute must contain a comma-separated list of:
406 * path to Terracotta configuration file (usually named tc-config.xml)
407 * URL to Terracotta configuration file
408 * <server host>:<port> of running Terracotta Server instance
409
410 Simplest example for pointing to a Terracotta server on this machine:
411 <terracottaConfig url="localhost:9510"/>
412
413 This element has one attribute "rejoin" which can take values of either "true" or "false":
414 <terracottaConfig rejoin="true" url="localhost:9510" />
415
416 By default, this attribute is false.
417
418 If rejoin is true, all Terracotta Clustered caches have to be configured with nonstop.
419 Without rejoin, if the Terracotta Server is restarted the client cannot connect back to the
420 server. When enabled, this allows the client to connect to the new cluster without the
421 need to restart the node.
422
423 Example using a path to Terracotta configuration file:
424 <terracottaConfig url="/app/config/tc-config.xml"/>
425
426 Example using a URL to a Terracotta configuration file:
427 <terracottaConfig url="http://internal/ehcache/app/tc-config.xml"/>
428
429 Example using multiple Terracotta server instance URLs (for fault tolerance):
430 <terracottaConfig url="host1:9510,host2:9510,host3:9510"/>
431
432 To embed a Terracotta configuration file within the ehcache configuration, simply
433 place a normal Terracotta XML config within the <terracottaConfig> element.
434
435 Example:
436 <terracottaConfig>
437 <tc-config>
438 <servers>
439 <server host="server1" name="s1"/>
440 <server host="server2" name="s2"/>
441 </servers>
442 <clients>
443 <logs>app/logs-%i</logs>
444 </clients>
445 </tc-config>
446 </terracottaConfig>
447
448 For more information on the Terracotta configuration, see the Terracotta documentation.
449 -->
450
451 <!--
452 Cache configuration
453 ===================
454
455 The following attributes are required.
456
457 name:
458 Sets the name of the cache. This is used to identify the cache. It must be unique.
459
460 maxEntriesLocalHeap:
461 Sets the maximum number of objects that will be created in memory. 0 = no limit.
462 In practice no limit means Integer.MAX_SIZE (2147483647) unless the cache is distributed
463 with a Terracotta server in which case it is limited by resources.
464
465 maxEntriesLocalDisk:
466 Sets the maximum number of objects that will be maintained in the DiskStore
467 The default value is zero, meaning unlimited.
468
469 eternal:
470 Sets whether elements are eternal. If eternal, timeouts are ignored and the
471 element is never expired.
472
473 The following attributes and elements are optional.
474
475 overflowToOffHeap:
476 (boolean) This feature is available only in enterprise versions of Ehcache.
477 When set to true, enables the cache to utilize off-heap memory
478 storage to improve performance. Off-heap memory is not subject to Java
479 GC. The default value is false.
480
481 maxBytesLocalHeap:
482 Defines how many bytes the cache may use from the VM's heap. If a CacheManager
483 maxBytesLocalHeap has been defined, this Cache's specified amount will be
484 subtracted from the CacheManager. Other caches will share the remainder.
485 This attribute's values are given as <number>k|K|m|M|g|G for
486 kilobytes (k|K), megabytes (m|M), or gigabytes (g|G).
487 For example, maxBytesLocalHeap="2g" allots 2 gigabytes of heap memory.
488 If you specify a maxBytesLocalHeap, you can't use the maxEntriesLocalHeap attribute.
489 maxEntriesLocalHeap can't be used if a CacheManager maxBytesLocalHeap is set.
490
491 Elements put into the cache will be measured in size using net.sf.ehcache.pool.sizeof.SizeOf
492 If you wish to ignore some part of the object graph, see net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf
493
494 maxBytesLocalOffHeap:
495 This feature is available only in enterprise versions of Ehcache.
496 Sets the amount of off-heap memory this cache can use, and will reserve.
497
498 This setting will set overflowToOffHeap to true. Set explicitly to false to disable overflow behavior.
499
500 Note that it is recommended to set maxEntriesLocalHeap to at least 100 elements
501 when using an off-heap store, otherwise performance will be seriously degraded,
502 and a warning will be logged.
503
504 The minimum amount that can be allocated is 128MB. There is no maximum.
505
506 maxBytesLocalDisk:
507 As for maxBytesLocalHeap, but specifies the limit of disk storage this cache will ever use.
508
509 timeToIdleSeconds:
510 Sets the time to idle for an element before it expires.
511 i.e. The maximum amount of time between accesses before an element expires
512 Is only used if the element is not eternal.
513 Optional attribute. A value of 0 means that an Element can idle for infinity.
514 The default value is 0.
515
516 timeToLiveSeconds:
517 Sets the time to live for an element before it expires.
518 i.e. The maximum time between creation time and when an element expires.
519 Is only used if the element is not eternal.
520 Optional attribute. A value of 0 means that and Element can live for infinity.
521 The default value is 0.
522
523 diskExpiryThreadIntervalSeconds:
524 The number of seconds between runs of the disk expiry thread. The default value
525 is 120 seconds.
526
527 diskSpoolBufferSizeMB:
528 This is the size to allocate the DiskStore for a spool buffer. Writes are made
529 to this area and then asynchronously written to disk. The default size is 30MB.
530 Each spool buffer is used only by its cache. If you get OutOfMemory errors consider
531 lowering this value. To improve DiskStore performance consider increasing it. Trace level
532 logging in the DiskStore will show if put back ups are occurring.
533
534 clearOnFlush:
535 whether the MemoryStore should be cleared when flush() is called on the cache.
536 By default, this is true i.e. the MemoryStore is cleared.
537
538 statistics:
539 Whether to collect statistics. Note that this should be turned on if you are using
540 the Ehcache Monitor. By default statistics is turned off to favour raw performance.
541 To enable set statistics="true"
542
543 memoryStoreEvictionPolicy:
544 Policy would be enforced upon reaching the maxEntriesLocalHeap limit. Default
545 policy is Least Recently Used (specified as LRU). Other policies available -
546 First In First Out (specified as FIFO) and Less Frequently Used
547 (specified as LFU)
548
549 copyOnRead:
550 Whether an Element is copied when being read from a cache.
551 By default this is false.
552
553 copyOnWrite:
554 Whether an Element is copied when being added to the cache.
555 By default this is false.
556
557 Cache persistence is configured through the persistence sub-element. The attributes of the
558 persistence element are:
559
560 strategy:
561 Configures the type of persistence provided by the configured cache. This must be one of the
562 following values:
563
564 * localRestartable - Enables the RestartStore and copies all cache entries (on-heap and/or off-heap)
565 to disk. This option provides fast restartability with fault tolerant cache persistence on disk.
566 It is available for Enterprise Ehcache users only.
567
568 * localTempSwap - Swaps cache entries (on-heap and/or off-heap) to disk when the cache is full.
569 "localTempSwap" is not persistent.
570
571 * none - Does not persist cache entries.
572
573 * distributed - Defers to the <terracotta> configuration for persistence settings. This option
574 is not applicable for standalone.
575
576 synchronousWrites:
577 When set to true write operations on the cache do not return until after the operations data has been
578 successfully flushed to the disk storage. This option is only valid when used with the "localRestartable"
579 strategy, and defaults to false.
580
581 The following example configuration shows a cache configured for localTempSwap restartability.
582
583 <cache name="persistentCache" maxEntriesLocalHeap="1000">
584 <persistence strategy="localTempSwap"/>
585 </cache>
586
587 Cache elements can also contain sub elements which take the same format of a factory class
588 and properties. Defined sub-elements are:
589
590 * cacheEventListenerFactory - Enables registration of listeners for cache events, such as
591 put, remove, update, and expire.
592
593 * bootstrapCacheLoaderFactory - Specifies a BootstrapCacheLoader, which is called by a
594 cache on initialisation to prepopulate itself.
595
596 * cacheExtensionFactory - Specifies a CacheExtension, a generic mechanism to tie a class
597 which holds a reference to a cache to the cache lifecycle.
598
599 * cacheExceptionHandlerFactory - Specifies a CacheExceptionHandler, which is called when
600 cache exceptions occur.
601
602 * cacheLoaderFactory - Specifies a CacheLoader, which can be used both asynchronously and
603 synchronously to load objects into a cache. More than one cacheLoaderFactory element
604 can be added, in which case the loaders form a chain which are executed in order. If a
605 loader returns null, the next in chain is called.
606
607 * copyStrategy - Specifies a fully qualified class which implements
608 net.sf.ehcache.store.compound.CopyStrategy. This strategy will be used for copyOnRead
609 and copyOnWrite in place of the default which is serialization.
610
611 Example of cache level resource tuning:
612 <cache name="memBound" maxBytesLocalHeap="100m" maxBytesLocalOffHeap="4g" maxBytesLocalDisk="200g" />
613
614
615 Cache Event Listeners
616 +++++++++++++++++++++
617
618 All cacheEventListenerFactory elements can take an optional property listenFor that describes
619 which events will be delivered in a clustered environment. The listenFor attribute has the
620 following allowed values:
621
622 * all - the default is to deliver all local and remote events
623 * local - deliver only events originating in the current node
624 * remote - deliver only events originating in other nodes
625
626 Example of setting up a logging listener for local cache events:
627
628 <cacheEventListenerFactory class="my.company.log.CacheLogger"
629 listenFor="local" />
630
631
632 Search
633 ++++++
634
635 A <cache> can be made searchable by adding a <searchable/> sub-element. By default the keys
636 and value objects of elements put into the cache will be attributes against which
637 queries can be expressed.
638
639 <cache>
640 <searchable/>
641 </cache>
642
643
644 An "attribute" of the cache elements can also be defined to be searchable. In the example below
645 an attribute with the name "age" will be available for use in queries. The value for the "age"
646 attribute will be computed by calling the method "getAge()" on the value object of each element
647 in the cache. See net.sf.ehcache.search.attribute.ReflectionAttributeExtractor for the format of
648 attribute expressions. Attribute values must also conform to the set of types documented in the
649 net.sf.ehcache.search.attribute.AttributeExtractor interface
650
651 <cache>
652 <searchable>
653 <searchAttribute name="age" expression="value.getAge()"/>
654 </searchable>
655 </cache>
656
657
658 Attributes may also be defined using a JavaBean style. With the following attribute declaration
659 a public method getAge() will be expected to be found on either the key or value for cache elements
660
661 <cache>
662 <searchable>
663 <searchAttribute name="age"/>
664 </searchable>
665 </cache>
666
667 In more complex situations you can create your own attribute extractor by implementing the
668 AttributeExtractor interface. Providing your extractor class is shown in the following example:
669
670 <cache>
671 <searchable>
672 <searchAttribute name="age" class="com.example.MyAttributeExtractor"/>
673 </searchable>
674 </cache>
675
676 Use properties to pass state to your attribute extractor if needed. Your implementation must provide
677 a public constructor that takes a single java.util.Properties instance
678
679 <cache>
680 <searchable>
681 <searchAttribute name="age" class="com.example.MyAttributeExtractor" properties="foo=1,bar=2"/>
682 </searchable>
683 </cache>
684
685
686 RMI Cache Replication
687 +++++++++++++++++++++
688
689 Each cache that will be distributed needs to set a cache event listener which replicates
690 messages to the other CacheManager peers. For the built-in RMI implementation this is done
691 by adding a cacheEventListenerFactory element of type RMICacheReplicatorFactory to each
692 distributed cache's configuration as per the following example:
693
694 <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
695 properties="replicateAsynchronously=true,
696 replicatePuts=true,
697 replicatePutsViaCopy=false,
698 replicateUpdates=true,
699 replicateUpdatesViaCopy=true,
700 replicateRemovals=true,
701 asynchronousReplicationIntervalMillis=<number of milliseconds>,
702 asynchronousReplicationMaximumBatchSize=<number of operations>"
703 propertySeparator="," />
704
705 The RMICacheReplicatorFactory recognises the following properties:
706
707 * replicatePuts=true|false - whether new elements placed in a cache are
708 replicated to others. Defaults to true.
709
710 * replicatePutsViaCopy=true|false - whether the new elements are
711 copied to other caches (true), or whether a remove message is sent. Defaults to true.
712
713 * replicateUpdates=true|false - whether new elements which override an
714 element already existing with the same key are replicated. Defaults to true.
715
716 * replicateRemovals=true - whether element removals are replicated. Defaults to true.
717
718 * replicateAsynchronously=true | false - whether replications are
719 asynchronous (true) or synchronous (false). Defaults to true.
720
721 * replicateUpdatesViaCopy=true | false - whether the new elements are
722 copied to other caches (true), or whether a remove message is sent. Defaults to true.
723
724 * asynchronousReplicationIntervalMillis=<number of milliseconds> - The asynchronous
725 replicator runs at a set interval of milliseconds. The default is 1000. The minimum
726 is 10. This property is only applicable if replicateAsynchronously=true
727
728 * asynchronousReplicationMaximumBatchSize=<number of operations> - The maximum
729 number of operations that will be batch within a single RMI message. The default
730 is 1000. This property is only applicable if replicateAsynchronously=true
731
732 JGroups Replication
733 +++++++++++++++++++
734
735 For the Jgroups replication this is done with:
736 <cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
737 properties="replicateAsynchronously=true, replicatePuts=true,
738 replicateUpdates=true, replicateUpdatesViaCopy=false,
739 replicateRemovals=true,asynchronousReplicationIntervalMillis=1000"/>
740 This listener supports the same properties as the RMICacheReplicationFactory.
741
742
743 JMS Replication
744 +++++++++++++++
745
746 For JMS-based replication this is done with:
747 <cacheEventListenerFactory
748 class="net.sf.ehcache.distribution.jms.JMSCacheReplicatorFactory"
749 properties="replicateAsynchronously=true,
750 replicatePuts=true,
751 replicateUpdates=true,
752 replicateUpdatesViaCopy=true,
753 replicateRemovals=true,
754 asynchronousReplicationIntervalMillis=1000"
755 propertySeparator=","/>
756
757 This listener supports the same properties as the RMICacheReplicationFactory.
758
759 Cluster Bootstrapping
760 +++++++++++++++++++++
761
762 Bootstrapping a cluster may use a different mechanism to replication. e.g you can mix
763 JMS replication with bootstrap via RMI - just make sure you have the cacheManagerPeerProviderFactory
764 and cacheManagerPeerListenerFactory configured.
765
766 There are two bootstrapping mechanisms: RMI and JGroups.
767
768 RMI Bootstrap
769
770 The RMIBootstrapCacheLoader bootstraps caches in clusters where RMICacheReplicators are
771 used. It is configured as per the following example:
772
773 <bootstrapCacheLoaderFactory
774 class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
775 properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
776 propertySeparator="," />
777
778 The RMIBootstrapCacheLoaderFactory recognises the following optional properties:
779
780 * bootstrapAsynchronously=true|false - whether the bootstrap happens in the background
781 after the cache has started. If false, bootstrapping must complete before the cache is
782 made available. The default value is true.
783
784 * maximumChunkSizeBytes=<integer> - Caches can potentially be very large, larger than the
785 memory limits of the VM. This property allows the bootstraper to fetched elements in
786 chunks. The default chunk size is 5000000 (5MB).
787
788 JGroups Bootstrap
789
790 Here is an example of bootstrap configuration using JGroups boostrap:
791
792 <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsBootstrapCacheLoaderFactory"
793 properties="bootstrapAsynchronously=true"/>
794
795 The configuration properties are the same as for RMI above. Note that JGroups bootstrap only supports
796 asynchronous bootstrap mode.
797
798
799 Cache Exception Handling
800 ++++++++++++++++++++++++
801
802 By default, most cache operations will propagate a runtime CacheException on failure. An
803 interceptor, using a dynamic proxy, may be configured so that a CacheExceptionHandler can
804 be configured to intercept Exceptions. Errors are not intercepted.
805
806 It is configured as per the following example:
807
808 <cacheExceptionHandlerFactory class="com.example.ExampleExceptionHandlerFactory"
809 properties="logLevel=FINE"/>
810
811 Caches with ExceptionHandling configured are not of type Cache, but are of type Ehcache only,
812 and are not available using CacheManager.getCache(), but using CacheManager.getEhcache().
813
814
815 Cache Loader
816 ++++++++++++
817
818 A default CacheLoader may be set which loads objects into the cache through asynchronous and
819 synchronous methods on Cache. This is different to the bootstrap cache loader, which is used
820 only in distributed caching.
821
822 It is configured as per the following example:
823
824 <cacheLoaderFactory class="com.example.ExampleCacheLoaderFactory"
825 properties="type=int,startCounter=10"/>
826
827 Element value comparator
828 ++++++++++++++++++++++++
829
830 These two cache atomic methods:
831 removeElement(Element e)
832 replace(Element old, Element element)
833
834 rely on comparison of cached elements value. The default implementation relies on Object.equals()
835 but that can be changed in case you want to use a different way to compute equality of two elements.
836
837 This is configured as per the following example:
838
839 <elementValueComparator class="com.company.xyz.MyElementComparator"/>
840
841 The MyElementComparator class must implement the is net.sf.ehcache.store.ElementValueComparator
842 interface. The default implementation is net.sf.ehcache.store.DefaultElementValueComparator.
843
844
845 SizeOf Policy
846 +++++++++++++
847
848 Control how deep the SizeOf engine can go when sizing on-heap elements.
849
850 This is configured as per the following example:
851
852 <sizeOfPolicy maxDepth="100" maxDepthExceededBehavior="abort"/>
853
854 maxDepth controls how many linked objects can be visited before the SizeOf engine takes any action.
855 maxDepthExceededBehavior specifies what happens when the max depth is exceeded while sizing an object graph.
856 "continue" makes the SizeOf engine log a warning and continue the sizing. This is the default.
857 "abort" makes the SizeOf engine abort the sizing, log a warning and mark the cache as not correctly tracking
858 memory usage. This makes Ehcache.hasAbortedSizeOf() return true when this happens.
859
860 The SizeOf policy can be configured at the cache manager level (directly under <ehcache>) and at
861 the cache level (under <cache> or <defaultCache>). The cache policy always overrides the cache manager
862 one if both are set. This element has no effect on distributed caches.
863
864 Transactions
865 ++++++++++++
866
867 To enable an ehcache as transactions, set the transactionalMode
868
869 transactionalMode="xa" - high performance JTA/XA implementation
870 transactionalMode="xa_strict" - canonically correct JTA/XA implementation
871 transactionMode="local" - high performance local transactions involving caches only
872 transactionalMode="off" - the default, no transactions
873
874 If set, all cache operations will need to be done through transactions.
875
876 To prevent users keeping references on stored elements and modifying them outside of any transaction's control,
877 transactions also require the cache to be configured copyOnRead and copyOnWrite.
878
879 CacheWriter
880 ++++++++++++
881
882 A CacheWriter can be set to write to an underlying resource. Only one CacheWriter can be
883 configured per cache.
884
885 The following is an example of how to configure CacheWriter for write-through:
886
887 <cacheWriter writeMode="write-through" notifyListenersOnException="true">
888 <cacheWriterFactory class="net.sf.ehcache.writer.TestCacheWriterFactory"
889 properties="type=int,startCounter=10"/>
890 </cacheWriter>
891
892 The following is an example of how to configure CacheWriter for write-behind:
893
894 <cacheWriter writeMode="write-behind" minWriteDelay="1" maxWriteDelay="5"
895 rateLimitPerSecond="5" writeCoalescing="true" writeBatching="true" writeBatchSize="1"
896 retryAttempts="2" retryAttemptDelaySeconds="1">
897 <cacheWriterFactory class="net.sf.ehcache.writer.TestCacheWriterFactory"
898 properties="type=int,startCounter=10"/>
899 </cacheWriter>
900
901 The cacheWriter element has the following attributes:
902 * writeMode: the write mode, write-through or write-behind
903
904 These attributes only apply to write-through mode:
905 * notifyListenersOnException: Sets whether to notify listeners when an exception occurs on a writer operation.
906
907 These attributes only apply to write-behind mode:
908 * minWriteDelay: Set the minimum number of seconds to wait before writing behind. If set to a value greater than 0,
909 it permits operations to build up in the queue. This is different from the maximum write delay in that by waiting
910 a minimum amount of time, work is always being built up. If the minimum write delay is set to zero and the
911 CacheWriter performs its work very quickly, the overhead of processing the write behind queue items becomes very
912 noticeable in a cluster since all the operations might be done for individual items instead of for a collection
913 of them.
914 * maxWriteDelay: Set the maximum number of seconds to wait before writing behind. If set to a value greater than 0,
915 it permits operations to build up in the queue to enable effective coalescing and batching optimisations.
916 * writeBatching: Sets whether to batch write operations. If set to true, writeAll and deleteAll will be called on
917 the CacheWriter rather than write and delete being called for each key. Resources such as databases can perform
918 more efficiently if updates are batched, thus reducing load.
919 * writeBatchSize: Sets the number of operations to include in each batch when writeBatching is enabled. If there are
920 less entries in the write-behind queue than the batch size, the queue length size is used.
921 * rateLimitPerSecond: Sets the maximum number of write operations to allow per second when writeBatching is enabled.
922 * writeCoalescing: Sets whether to use write coalescing. If set to true and multiple operations on the same key are
923 present in the write-behind queue, only the latest write is done, as the others are redundant.
924 * retryAttempts: Sets the number of times the operation is retried in the CacheWriter, this happens after the
925 original operation.
926 * retryAttemptDelaySeconds: Sets the number of seconds to wait before retrying an failed operation.
927
928 Cache Extension
929 +++++++++++++++
930
931 CacheExtensions are a general purpose mechanism to allow generic extensions to a Cache.
932 CacheExtensions are tied into the Cache lifecycle.
933
934 CacheExtensions are created using the CacheExtensionFactory which has a
935 <code>createCacheCacheExtension()</code> method which takes as a parameter a
936 Cache and properties. It can thus call back into any public method on Cache, including, of
937 course, the load methods.
938
939 Extensions are added as per the following example:
940
941 <cacheExtensionFactory class="com.example.FileWatchingCacheRefresherExtensionFactory"
942 properties="refreshIntervalMillis=18000, loaderTimeout=3000,
943 flushPeriod=whatever, someOtherProperty=someValue ..."/>
944
945 Cache Decorator Factory
946 +++++++++++++++++++++++
947
948 Cache decorators can be configured directly in ehcache.xml. The decorators will be created and added to the CacheManager.
949 It accepts the name of a concrete class that extends net.sf.ehcache.constructs.CacheDecoratorFactory
950 The properties will be parsed according to the delimiter (default is comma ',') and passed to the concrete factory's
951 <code>createDecoratedEhcache(Ehcache cache, Properties properties)</code> method along with the reference to the owning cache.
952
953 It is configured as per the following example:
954
955 <cacheDecoratorFactory
956 class="com.company.DecoratedCacheFactory"
957 properties="property1=true ..." />
958
959 Distributed Caching with Terracotta
960 +++++++++++++++++++++++++++++++++++
961
962 Distributed Caches connect to a Terracotta Server Array. They are configured with the <terracotta> sub-element.
963
964 The <terracotta> sub-element has the following attributes:
965
966 * clustered=true|false - indicates whether this cache should be clustered (distributed) with Terracotta. By
967 default, if the <terracotta> element is included, clustered=true.
968
969 * valueMode=serialization|identity - the default is serialization
970
971 Indicates whether cache Elements are distributed with serialized copies or whether a single copy
972 in identity mode is distributed.
973
974 The implications of Identity mode should be clearly understood with reference to the Terracotta
975 documentation before use.
976
977 * copyOnRead=true|false - indicates whether cache values are deserialized on every read or if the
978 materialized cache value can be re-used between get() calls. This setting is useful if a cache
979 is being shared by callers with disparate classloaders or to prevent local drift if keys/values
980 are mutated locally without being put back in the cache.
981
982 The default is false.
983
984 Note: This setting is only relevant for caches with valueMode=serialization
985
986 * consistency=strong|eventual - Indicates whether this cache should have strong consistency or eventual
987 consistency. The default is eventual. See the documentation for the meaning of these terms.
988
989 * synchronousWrites=true|false
990
991 Synchronous writes (synchronousWrites="true") maximize data safety by blocking the client thread until
992 the write has been written to the Terracotta Server Array.
993
994 This option is only available with consistency=strong. The default is false.
995
996 * concurrency - the number of segments that will be used by the map underneath the Terracotta Store.
997 Its optional and has default value of 0, which means will use default values based on the internal
998 Map being used underneath the store.
999
1000 This value cannot be changed programmatically once a cache is initialized.
1001
1002 The <terracotta> sub-element also has a <nonstop> sub-element to allow configuration of cache behaviour if a distributed
1003 cache operation cannot be completed within a set time or in the event of a clusterOffline message. If this element does not appear, nonstop behavior is off.
1004
1005 <nonstop> has the following attributes:
1006
1007 * enabled="true" - defaults to true.
1008
1009 * timeoutMillis - An SLA setting, so that if a cache operation takes longer than the allowed ms, it will timeout.
1010
1011 * immediateTimeout="true|false" - What to do on receipt of a ClusterOffline event indicating that communications
1012 with the Terracotta Server Array were interrupted.
1013
1014 <nonstop> has one sub-element, <timeoutBehavior> which has the following attribute:
1015
1016 * type="noop|exception|localReads" - What to do when a timeout has occurred. Exception is the default.
1017
1018 Simplest example to indicate clustering:
1019 <terracotta/>
1020
1021 To indicate the cache should not be clustered (or remove the <terracotta> element altogether):
1022 <terracotta clustered="false"/>
1023
1024 To indicate the cache should be clustered using identity mode:
1025 <terracotta clustered="true" valueMode="identity"/>
1026
1027 To indicate the cache should be clustered using "eventual" consistency mode for better performance :
1028 <terracotta clustered="true" consistency="eventual"/>
1029
1030 To indicate the cache should be clustered using synchronous-write locking level:
1031 <terracotta clustered="true" synchronousWrites="true"/>
1032 -->
1033
1034 <!--
1035 Default Cache configuration. These settings will be applied to caches
1036 created programmatically using CacheManager.add(String cacheName).
1037 This element is optional, and using CacheManager.add(String cacheName) when
1038 its not present will throw CacheException
1039
1040 The defaultCache has an implicit name "default" which is a reserved cache name.
1041 -->
1042 <defaultCache
1043 maxEntriesLocalHeap="10000"
1044 eternal="false"
1045 timeToIdleSeconds="120"
1046 timeToLiveSeconds="120"
1047 diskSpoolBufferSizeMB="30"
1048 maxEntriesLocalDisk="10000000"
1049 diskExpiryThreadIntervalSeconds="120"
1050 memoryStoreEvictionPolicy="LRU"
1051 statistics="false">
1052 <persistence strategy="localTempSwap"/>
1053 </defaultCache>
1054
1055 <!--
1056 Sample caches. Following are some example caches. Remove these before use.
1057 -->
1058
1059 <!--
1060 Sample cache named sampleCache1
1061 This cache contains a maximum in memory of 10000 elements, and will expire
1062 an element if it is idle for more than 5 minutes and lives for more than
1063 10 minutes.
1064
1065 If there are more than 10000 elements it will overflow to the
1066 disk cache, which in this configuration will go to wherever java.io.tmp is
1067 defined on your system. On a standard Linux system this will be /tmp"
1068 -->
1069 <cache name="sampleCache1"
1070 maxEntriesLocalHeap="10000"
1071 maxEntriesLocalDisk="1000"
1072 eternal="false"
1073 diskSpoolBufferSizeMB="20"
1074 timeToIdleSeconds="300"
1075 timeToLiveSeconds="600"
1076 memoryStoreEvictionPolicy="LFU"
1077 transactionalMode="off">
1078 <persistence strategy="localTempSwap"/>
1079 </cache>
1080
1081
1082 <!--
1083 Sample cache named sampleCache2
1084 This cache has a maximum of 1000 elements in memory. There is no overflow to disk, so 1000
1085 is also the maximum cache size. Note that when a cache is eternal, timeToLive and
1086 timeToIdle are not used and do not need to be specified.
1087 -->
1088 <cache name="sampleCache2"
1089 maxEntriesLocalHeap="1000"
1090 eternal="true"
1091 memoryStoreEvictionPolicy="FIFO"
1092 />
1093
1094
1095 <!--
1096 Sample cache named sampleCache3. This cache overflows to disk. The disk store is
1097 persistent between cache and VM restarts. The disk expiry thread interval is set to 10
1098 minutes, overriding the default of 2 minutes.
1099 -->
1100 <cache name="sampleCache3"
1101 maxEntriesLocalHeap="500"
1102 eternal="false"
1103 overflowToDisk="true"
1104 diskPersistent="true"
1105 timeToIdleSeconds="300"
1106 timeToLiveSeconds="600"
1107 diskExpiryThreadIntervalSeconds="1"
1108 memoryStoreEvictionPolicy="LFU">
1109 </cache>
1110
1111
1112 <!--
1113 Sample distributed cache named sampleReplicatedCache1.
1114 This cache replicates using defaults.
1115 It also bootstraps from the cluster, using default properties.
1116 -->
1117 <cache name="sampleReplicatedCache1"
1118 maxEntriesLocalHeap="10"
1119 eternal="false"
1120 timeToIdleSeconds="100"
1121 timeToLiveSeconds="100">
1122
1123 <cacheEventListenerFactory
1124 class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
1125 <bootstrapCacheLoaderFactory
1126 class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
1127 </cache>
1128
1129
1130 <!--
1131 Sample distributed cache named sampleReplicatedCache2.
1132 This cache replicates using specific properties.
1133 It only replicates updates and does so synchronously via copy
1134 -->
1135 <cache name="sampleRepicatedCache2"
1136 maxEntriesLocalHeap="10"
1137 eternal="false"
1138 timeToIdleSeconds="100"
1139 timeToLiveSeconds="100">
1140 <cacheEventListenerFactory
1141 class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
1142 properties="replicateAsynchronously=false, replicatePuts=false,
1143 replicatePutsViaCopy=false, replicateUpdates=true,
1144 replicateUpdatesViaCopy=true, replicateRemovals=false"/>
1145 </cache>
1146
1147 <!--
1148 Sample distributed cache named sampleReplicatedCache3.
1149 This cache replicates using defaults except that the asynchronous replication
1150 interval is set to 200ms.
1151 This one includes / and # which were illegal in ehcache 1.5.
1152 -->
1153 <cache name="sampleReplicatedCache3"
1154 maxEntriesLocalHeap="10"
1155 eternal="false"
1156 timeToIdleSeconds="100"
1157 timeToLiveSeconds="100">
1158 <cacheEventListenerFactory
1159 class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
1160 properties="asynchronousReplicationIntervalMillis=200"/>
1161 <persistence strategy="localTempSwap"/>
1162 </cache>
1163
1164 <!--
1165 Sample Terracotta clustered cache named sampleTerracottaCache.
1166 This cache uses Terracotta to cluster the contents of the cache.
1167 -->
1168 <!--
1169 <cache name="sampleTerracottaCache"
1170 maxBytesLocalHeap="10m"
1171 eternal="false"
1172 timeToIdleSeconds="3600"
1173 timeToLiveSeconds="1800">
1174 <terracotta/>
1175 </cache>
1176 -->
1177
1178 <!--
1179 Sample xa enabled cache named xaCache
1180 <cache name="xaCache"
1181 maxEntriesLocalHeap="500"
1182 eternal="false"
1183 timeToIdleSeconds="300"
1184 timeToLiveSeconds="600"
1185 diskExpiryThreadIntervalSeconds="1"
1186 transactionalMode="xa_strict">
1187 </cache>
1188 -->
1189
1190 <!--
1191 Sample copy on both read and write cache named copyCache
1192 using the default (explicitly configured here as an example) ReadWriteSerializationCopyStrategy
1193 class could be any implementation of net.sf.ehcache.store.compound.CopyStrategy
1194 <cache name="copyCache"
1195 maxEntriesLocalHeap="500"
1196 eternal="false"
1197 timeToIdleSeconds="300"
1198 timeToLiveSeconds="600"
1199 diskExpiryThreadIntervalSeconds="1"
1200 copyOnRead="true"
1201 copyOnWrite="true">
1202 <copyStrategy class="net.sf.ehcache.store.compound.ReadWriteSerializationCopyStrategy" />
1203 </cache>
1204 -->
1205 <!--
1206 Sample, for Enterprise Ehcache only, demonstrating a tiered cache with in-memory, off-heap and disk stores. In this example the in-memory (on-heap) store is limited to 10,000 items ... which for example for 1k items would use 10MB of memory, the off-heap store is limited to 4GB and the disk store is unlimited in size.
1207 <cache name="tieredCache"
1208 maxEntriesLocalHeap="10000"
1209 eternal="false"
1210 timeToLiveSeconds="600"
1211 overflowToOffHeap="true"
1212 maxBytesLocalOffHeap="4g"
1213 diskExpiryThreadIntervalSeconds="1">
1214 <persistence strategy="localTempSwap"/>
1215 </cache>
1216 -->
1217 <!--
1218 Sample, for Enterprise Ehcache only, demonstrating a restartable cache with in-memory and off-heap stores.
1219 <cache name="restartableCache"
1220 maxEntriesLocalHeap="10000"
1221 eternal="true"
1222 overflowToOffHeap="true"
1223 maxBytesLocalOffHeap="4g"
1224 <persistence strategy="localRestartable"/>
1225 </cache>
1226 -->
1227 </ehcache>