ehcache.xml详解

本文详细介绍了EHCache的配置参数,包括缓存文件路径设定、默认缓存配置及特定缓存配置等。阐述了如何通过调整最大内存对象数、是否永恒、溢出到磁盘等属性来优化缓存性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
    <!-- Sets the path to the directory where cache .data files are created.
    设置缓存文件被创建的目录路径
     If the path is a Java System Property it is replaced by
     its value in the running VM.
如果这个路径是Java System Property,那么这个路径就会被这个属性值所替代
     The following properties are translated:
     user.home - User's home directory
     user.dir - User's current working directory
     java.io.tmpdir - Default temp file path -->

    <!--Default Cache configuration. These will applied to caches programmatically created through
        the CacheManager.

        The following attributes are required:

        maxElementsInMemory            - Sets the maximum number of objects that will be created in memory
                                        设置内存中创建的最大对象个数
        eternal                                     - Sets whether elements are eternal. If eternal,  timeouts are ignored and the element is never expired.
                                                    设置元素是否永恒,如果永恒,那么将忽略超时限制并且该元素永远不会过期
        overflowToDisk                      - Sets whether elements can overflow to disk when the in-memory cache has reached the maxInMemory limit.
                                            设置在内存中的缓存达到打到最大的对象数时是否允许溢出到磁盘

        The following attributes are optional:
        timeToIdleSeconds            -     Sets the time to idle for an element before it expires.    
                                        设置元素过期之前的空闲时间                                    
                                                        i.e. The maximum amount of time between accesses before an
                                                        element expires Is only used if the element is not eternal.
                                                        Optional attribute. A value of 0 means that an Element can idle
                                                        for infinity.The default value is 0.
        timeToLiveSeconds              - Sets the time to live for an element before it expires.
                                        设置元素过期之前的时间
                                                         i.e. The maximum time between creation time and when an element
                                                         expires.  Is only used if the element is not eternal.
                                                         Optional attribute. A value of 0 means that and Element can live
                                                         for infinity.
                                                        The default value is 0.
        diskPersistent                           - Whether the disk store persists between restarts of the Virtual Machine.
                                                    在重启虚拟机后磁盘存储是否还存在
                                                         The default value is false.
        diskExpiryThreadIntervalSeconds   - The number of seconds between runs of the disk expiry thread.
                                            磁盘失效线程之间的运行秒数。
                                                         The default value  is 120 seconds.
        --> <diskStore path="/data/ehcache"/> <defaultCache maxElementsInMemory="10000" eternal="false" overflowToDisk="true" timeToIdleSeconds="120" timeToLiveSeconds="180" diskPersistent="false" diskExpiryThreadIntervalSeconds="60" /> <cache name="org.hibernate.cache.StandardQueryCache" maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="4200" overflowToDisk="true" /> <cache name="org.hibernate.cache.UpdateTimestampsCache" maxElementsInMemory="5000" eternal="true" timeToIdleSeconds="0" timeToLiveSeconds="0" overflowToDisk="false" /> </ehcache>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值