ehcache中详解参数

为了搞清楚timeToLiveSeconds和timeToIdleSeconds这两个参数的作用有必要
shiro-ehcache.jar中ehcache.xml的解释

<!--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.
    memoryStoreEvictionPolicy      - Policy would be enforced upon reaching the maxElementsInMemory limit. Default
                                     policy is Least Recently Used (specified as LRU). Other policies available -
                                     First In First Out (specified as FIFO) and Less Frequently Used
                                     (specified as LFU)
    -->
  • maxElementsInMemory
    • 内存中最大的元素个数,如果超过最大数量,overflowToDisk决定是否存储到磁盘上
  • eternal
    • 是否永久有效。
    • 如果eternal=true,那么timeToLiveSeconds、timeToIdleSeconds失效。
    • 如果eternal=false,那么timeToLiveSeconds、timeToIdleSeconds才起作用。
  • overflowToDisk
    • 当内存中达到最大元素数量?为true则存储到 磁盘上,否则?根据memoryStoreEvictionPolicy决定清除策略
  • timeToIdleSeconds
    • 最大空闲时间,单位为秒,元素过期前最大的访问间隔,0为永久空闲,在eternal=false时,有效。
  • timeToLiveSeconds
    • 最大存活时间,单位为秒,创建时间和失效时间的间隔,0为永久空闲,在eternal=false时,有效。
  • diskPersistent
    • jvm重启时,是否保留磁盘存储块,默认不保留
  • diskExpiryThreadIntervalSeconds
    • check磁盘块过期的间隔时间,默认2分钟
  • memoryStoreEvictionPolicy
    • 内存存储清除策略,当达到最大maxElementsInMemory限制时采用的策略,有 Least Recently Used (specified as LRU)、First In First Out (specified as FIFO)、Less Frequently Used,默认是LRU
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值