Copy the code code 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: The maximum number of cached items.
Eternal: Whether the object is permanently valid. Once set, timeout will have no effect.
timeToIdleSeconds: The allowed idle time (seconds) before the object expires. Used when eternal=false, optional attribute, the default value is 0, which means the idle time is infinite.
timeToLiveSeconds: The allowed survival time (seconds) of an object before it expires. The maximum time is between the creation time and the expiration time. Used when eternal=false, the default is 0, which means the object survival time is infinite.
overflowToDisk: When the number of objects in memory reaches maxElementsInMemory, Ehcache writes the objects to disk.
diskSpoolBufferSizeMB: This parameter sets the buffer size of DiskStore (disk cache). The default is 30MB. Each Cache should have its own buffer.
maxElementsOnDisk: The maximum number of hard disk caches.
diskPersistent: Whether to cache virtual machine restart data. The default value is false.
diskExpiryThreadIntervalSeconds: disk failure thread running time interval, the 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, first out) or LFU (less frequently used).
clearOnFlush: Whether to clear the memory when the maximum amount is reached.
<diskStore> means that when the number of objects in the memory cache exceeds the number of memory caches set by the class, the cache objects will be written to the hard disk. path="java.io.tmpdir" means that the data will be written to this directory. The Java.io.tmpdir directory will be generated based on the relative path at runtime.
<defaultCache> indicates setting the cache's default data expiration policy.
<cache> indicates setting the data expiration policy for cached data with a specific name.