Introduction to ehcache. xml in the java web project, webehcache. xml
Copy codeThe Code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Ehcache xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: noNamespaceSchemaLocation = "ehcache. xsd" updateCheck = "false"
Monitoring = "autodetect" dynamicConfig = "true">
<DiskStore path = "java. io. tmpdir"/>
<DefaultCache maxElementsInMemory = "10000" eternal = "true"
OverflowToDisk = "true"
MaxElementsOnDisk = "10000000" diskPersistent = "false"
DiskExpiryThreadIntervalSeconds = "120" memoryStoreEvictionPolicy = "LRU"/>
</Ehcache>
Name: cache name.
MaxElementsInMemory: Maximum number of caches.
Eternal: whether the object is permanently valid. Once set, timeout does not work.
TimeToIdleSeconds: The allowable idle time (in seconds) before the object expires ). This parameter is optional when eternal is set to false. The default value is 0, indicating that the idle time is infinite.
TimeToLiveSeconds: Specifies the lifetime (in seconds) of the object before it expires ). the maximum time is between the creation time and the expiration time. this parameter is used when eternal is set to false. The default value is 0, that is, the object survival time is infinite.
OverflowToDisk: when the number of objects in the memory reaches maxElementsInMemory, Ehcache writes the objects to the disk.
DiskSpoolBufferSizeMB: this parameter sets the cache size of DiskStore (disk cache. The default value is 30 MB. Each Cache should have its own buffer.
MaxElementsOnDisk: Maximum number of Hard Disk caches.
DiskPersistent: Indicates whether to cache data during VM restart. The default value is false.
DiskExpiryThreadIntervalSeconds: Specifies the interval for running a disk failure thread. The default value is 120 seconds.
MemoryStoreEvictionPolicy: When the maxElementsInMemory limit is reached, Ehcache clears the memory according to the specified policy. The default policy is LRU (least recently used ). You can set it to FIFO (first-in-first-out) or LFU (rarely used ).
ClearOnFlush: whether to clear when the maximum number of memory is exceeded.
<DiskStore> indicates that when the number of objects in the memory cache exceeds the class-set memory cache quantity, the cached objects are written to the hard disk, path = "java. io. tmpdir indicates writing data to this directory. The Java. io. tmpdir directory is generated according to the relative path at runtime.
<DefaultCache> sets the default cache data expiration policy.
<Cache> indicates setting a data expiration Policy for caching with a specific name.