这两个参数很容易误解,看文档根本没用,我仔细分析了ehcache的代码。结论如下:
1、timeToLiveSeconds的定义是:以创建时间为基准开始计算的超时时长;
2、timeToIdleSeconds的定义是:在创建时间和最近访问时间中取出离现在最近的时间作为基准计算的超时时长;
3、如果仅设置了timeToLiveSeconds,则该对象的超时时间=创建时间+timeToLiveSeconds,假设为A;
4、如果没设置timeToLiveSeconds,则该对象的超时时间=min(创建时间,最近访问时间)+timeToIdleSeconds,假设为B;
5、如果两者都设置了,则取出A、B最少的值,即min(A,B),表示只要有一个超时成立即算超时。
为了更好理解,可直接查看代码。摘自:net.sf.ehcache.Element.java(版本1.2.4):
/** * Returns the expiration time based on time to live. If this element also has a time to idle setting, the expiry * time will vary depending on whether the element is accessed. * * @return the time to expiration */ public long getExpirationTime() { if (!lifespanSet || eternal || (timeToLive == 0 && timeToIdle == 0)) { return Long.MAX_VALUE; } long expirationTime = 0; long ttlExpiry = creationTime + timeToLive * ONE_SECOND; long mostRecentTime = Math.max(creationTime, nextToLastAccessTime); long ttiExpiry = mostRecentTime + timeToIdle * ONE_SECOND; if (timeToLive != 0 && (timeToIdle == 0 || lastAccessTime == 0)) { expirationTime = ttlExpiry; } else if (timeToLive == 0) { expirationTime = ttiExpiry; } else { expirationTime = Math.min(ttlExpiry, ttiExpiry); } return expirationTime; }
相关推荐
ehcache.xml配置内容 <ehcache xmlns:xsi=... timeToIdleSeconds="120" timeToLiveSeconds="120" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" /> </ehcache>
在\ehcache-monitor-kit-1.0.0\etc\ehcache-monitor.conf中可以配置监控的ip和端口号。 4.启动被监控的web application和ehcache-monitor-kit-1.0.0\bin目录下的startup.bat(在windows环境下) 5.在浏览器中输入 ...
ehcache3-samples, 关于使用 Ehcache 3,一些示例/教程 Ehcache示例这里知识库包含有关 Ehcache 3用法的示例和教程。示例'basic'演示 Ehcache 3的基本配置和用法'集群'- 演示如何在Terracotta服务器上使用分布式缓存...
hibernate+ehcache hibernate+ehcache hibernate+ehcache hibernate+ehcache hibernate+ehcache
ehcache1.6,ehcache-web-2.0.4,slf4j-api-1.7.21.jar 不好意思,缺点分用。。
ehcache和h2 database资料
包含EHCache.jar和EHCache 技术文档.pdf
timeToIdleSeconds="300" !-- 当缓存闲置n秒后销毁 --> timeToLiveSeconds="180" !-- 当缓存存活n秒后销毁--> diskPersistent="false" diskExpiryThreadIntervalSeconds= "120"/> </ehcache>
赠送jar包:ehcache-3.9.9.jar; 赠送原API文档:ehcache-3.9.9-javadoc.jar; 赠送源代码:ehcache-3.9...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。 双语对照,边学技术、边学英语。
一个ehcache的简单示例,我只是留个备份,你们想要可以私聊我
ehcache-3.8.1.jar
EhCache 是一个纯 Java 的进程内缓存框架,具有快速、精干等特点,是 Hibernate 中默认的 CacheProvider。Ehcache 是一种广泛使用的开源 Java 分布式缓存。主要面向通用缓存,Java EE 和轻量级容器。它具有内存和...
赠送jar包:ehcache-3.3.1.jar; 赠送原API文档:ehcache-3.3.1-javadoc.jar; 赠送源代码:ehcache-3.3.1-sources.jar;...人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
ehcache缓存的jar包和配置文件。
EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是Hibernate中默认的CacheProvider。 Ehcache是一种广泛使用的开源Java分布式缓存。主要面向通用缓存,Java EE和轻量级容器。它具有内存和磁盘存储,...
hibernate ehcache.xml 配置详解
ehcache和memcache性能比较
ehcache所需jar包 cglib-nodep-2.2.jar ehcache-core-2.5.2.jar ehcache-spring-annotations-1.2.0.jar guava-13.0.1.jar ehcache-terracotta-2.5.2.jar slf4j-api-1.6.1.jar slf4j-log4j12-1.6.1.jar terracotta-...
Ehcache中文指南和实例教程 好东西来的, 入门必备
EhCache