First, ehcache.xml configuration detailed
Stand-alone configuration:
<ehcache xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation= ". /config/ehcache.xsd ">
<diskstore path= "D:/mycache"/>
<!--
Mandatory Default Cache configuration. These settings'll be applied to caches
Created programmtically using Cachemanager.add (String cachename)
-
<!--
Name: Cache names.
Maxelementsinmemory: Maximum number of caches.
Eternal: The object is permanently valid, but if set, timeout will not work.
Timetoidleseconds: Sets the allowable idle time (in seconds) for an object before it expires. An optional property is used only if the Eternal=false object is not permanently valid, and the default value is 0, which means that the idle time is infinite.
Timetoliveseconds: Sets the time (in seconds) that an object is allowed to survive before it expires. The maximum time is between the creation time and the expiration time. Used only when the Eternal=false object is not permanently valid, the default is 0, which means that the object survives indefinitely.
Overflowtodisk: When the number of objects in memory reaches Maxelementsinmemory, Ehcache writes the object to disk.
DISKSPOOLBUFFERSIZEMB: This parameter sets the buffer size of the Diskstore (disk cache). The default is 30MB. Each cache should have its own buffer.
Maxelementsondisk: Maximum number of hard disk caches.
Diskpersistent: Whether to cache VM Restart period data Whether The disk store persists between restarts of the virtual machine. The default value is False.
Diskexpirythreadintervalseconds: Disk failed thread run time interval, default is 120 seconds.
Memorystoreevictionpolicy: When the maxelementsinmemory limit is reached, Ehcache will clean up the memory according to the specified policy. The default policy is LRU (least recently used). You can set it to FIFO (first in, out) or LFU (less used).
Clearonflush: If the maximum amount of memory is cleared.
-
<defaultcache
Maxelementsinmemory= "10000"
Eternal= "false"
Timetoidleseconds= "120"
Timetoliveseconds= "120"
Overflowtodisk= "true"
maxelementsondisk= "10000000"
Diskpersistent= "false"
Diskexpirythreadintervalseconds= "120"
Memorystoreevictionpolicy= "LRU"
/>
<cache name= "K_dict"
maxelementsinmemory= "100"
maxelementsondisk= "0"
Eternal= "false"
Timetoidleseconds= "120"
timetoliveseconds= "0" >
<persistence strategy= "Localtempswap"/>
</cache>
</ehcache>
Distributed configuration:
<?xml version= "1.0" encoding= "UTF-8"?>
<ehcache xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:nonamespaceschemalocation= "Ehcache.xsd"
Updatecheck= "true" monitoring= "AutoDetect"
Dynamicconfig= "true" >
<diskstore path= "Java.io.tmpdir"/>
<!--Specify a list of other hosts in the network group other than themselves that provide synchronization, using the ' | ' Separate different hosts--
<cachemanagerpeerproviderfactory
Class= "Net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties= "Peerdiscovery=manual,rmiurls=//localhost:40004/metacache|//localhost:60000/metacache"/>
<!--with host configuration listener to discover synchronization requests from other hosts--
<cachemanagerpeerlistenerfactory
Class= "Net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties= "port=40004,sockettimeoutmillis=120000"/>
<!--default Cache--
<defaultcache maxelementsinmemory= "10000" eternal= "false"
timetoidleseconds= "timetoliveseconds=" overflowtodisk= "true"
diskspoolbuffersizemb= "maxelementsondisk=" 10000000 "
Diskpersistent= "false" diskexpirythreadintervalseconds= "120"
memorystoreevictionpolicy= "LRU" >
</defaultCache>
<!--Cache--
<cache name= "Metacache"
maxelementsinmemory= "1000"
Eternal= "false"
Timetoidleseconds= "2000"
timetoliveseconds= "1000"
Overflowtodisk= "false" >
<cacheeventlistenerfactory
class= "Net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
<!--<bootstrapcacheloaderfactory
Class= "Net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties= "Bootstrapasynchronously=true"/>--
</cache>
</ehcache>
Second, detailed introduction http://raychase.iteye.com/blog/1545906
Ehcache Java Open Source caching framework