Ehcache.xml Configuration Detailed

Source: Internet
Author: User

One: Configuration file case

1 <Ehcache>2 3     4     <!-- 5 disk Storage: Transfer objects temporarily unused in the cache to the hard disk, similar to the virtual memory of the Windows system6 Path : Specifies the path to the storage object on the hard disk7       -8     <DiskstorePath= "Java.io.tmpdir" />9 Ten      One     <!--  A Defaultcache: Default cache configuration information, if not specified, all objects are processed according to this configuration item - maxelementsinmemory: Sets the upper limit of the cache and stores the maximum number of record objects - Eternal: Indicates whether the object never expires the Timetoidleseconds: The biggest daze time - timetoliveseconds: Maximum time to live - Overflowtodisk: Whether an object is allowed to be written to disk -       - +     <Defaultcachemaxelementsinmemory= "10000"Eternal= "false" - Timetoidleseconds= "+"Timetoliveseconds= "+"Overflowtodisk= "true" /> +      A     <!--  at Cache : Special configuration for caching objects of the specified name - Name: Specify the full name of the object -       - -     <Cachename= "Com.zbaccp.entity.Person"maxelementsinmemory= "10000"Eternal= "false" - Timetoidleseconds= "+"Timetoliveseconds= "All"Overflowtodisk= "true" /> -  in  - </Ehcache>

Second: The property detailed

1. Diskstore: Specifies the data (. Data and. Index) storage location, which specifies the folder location period of the disk, the Diskstore element is optional. It must is configured if you have the Overflowtodisk or diskpersistent enabled for any cache. If It is not configured, a warning would be issues and java.io.tmpdir would be used.


2, Defaultcache: The default management policy


The following attributes are required:
1, Name:cache name, must be unique (Ehcache will put this cache in HashMap).
2. Maxelementsinmemory: The maximum number of element that is cached in memory.
3. Maxelementsondisk: The maximum number of element that is cached on disk, the default value is 0, which means no limit.
4. Eternal: Sets whether the cached elements will never expire. If true, the cached data is always valid, and if False then it is judged according to Timetoidleseconds,timetoliveseconds.
5, Overflowtodisk: If the in-memory data exceeds the memory limit, whether to cache to disk.
Second, the following properties are optional:
1, Timetoidleseconds: Object idle time, refers to how long the object is not accessed will be invalidated. Valid only for eternal to false. The default value of 0 indicates that access is always available.
2, Timetoliveseconds: Object survival time, refers to the object from creation to the expiration of the time required. Valid only for eternal to false. The default value of 0 indicates that access is always available.
3, Diskpersistent: Whether to persist on disk. Indicates whether the data is valid after restarting the JVM. The default is False.
4. Diskexpirythreadintervalseconds: Object detects thread run time interval. How long the thread that identifies the state of the object runs once.
5, the Diskspoolbuffersizemb:diskstore uses the disk size, the default value 30MB. Each cache uses its own diskstore.
6. Memorystoreevictionpolicy: If the in-memory data exceeds the memory limit, the policy is cached to disk. Default LRU, optional FIFO, LFU.
Three, 3 kinds of cache emptying policy:
1, FIFO, first Out (LIFO).
2, LFU, less frequently Used (minimum use). It means that it has been used at least for a long time. The cached element has a hit attribute, and the least hits value is cleared out of the cache.
3, LRU, Least recently used (least recently used). (ehcache default). The cached element has a timestamp, and when the cache is full and you need to make room to cache the new element, the element with the time stamp in the existing cache element that is farthest from the current time is cleared out of the cache.

Ehcache.xml Configuration Detailed

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.