关于ehache的文档说:
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
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.
Run Code Online (Sandbox Code Playgroud)
我理解timeToIdleSeconds
但这是否意味着在创建和首次访问缓存项后,timeToLiveSeconds不再适用?
Bor*_*vić 149
timeToIdleSeconds只要在短于的时间内请求缓存对象,就可以使缓存对象保持在timeToIdleSeconds.timeToLiveSeconds无论多少次或何时请求,都会使缓存的对象在该秒后失效.
我们这样说吧timeToIdleSeconds = 3.如果4秒钟内没有请求对象,则该对象将失效.
如果timeToLiveSeconds = 90,那么该对象将在90秒后从缓存中移除,即使它在其短寿命的第90秒中被请求了几毫秒.
Lee*_*iam 40
如果你设置两者,那expirationTime将是Math.min(ttlExpiry, ttiExpiry),在哪里
ttlExpiry = creationTime + timeToLive
ttiExpiry = mostRecentTime + timeToIdle
Run Code Online (Sandbox Code Playgroud)
这里有完整的源代码.
Dam*_*amo 22
从旧的1.1文档(可在Google Cache中获取,比当前文档AFAIK更易于浏览和提供更多信息):
timeToIdleSeconds
这是一个可选属性.
合法值是介于0和Integer.MAX_VALUE之间的整数.
它是Element自上次使用以来应该生存的秒数.使用的意思是插入或访问.
0具有特殊含义,不检查Element的空闲时间,即它将永远空闲.
默认值为0.
timeToLiveSeconds
这是一个可选属性.
合法值是介于0和Integer.MAX_VALUE之间的整数.
它是元素自创建以来应该生存的秒数.创建使用Cache.put方法插入缓存的方法.
0具有特殊含义,不检查Element的生存时间,即它将永远存在.
默认值为0.
| 归档时间: |
|
| 查看次数: |
54988 次 |
| 最近记录: |