Introduction to ehcache. xml in the java web project, webehcache. xml

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.