gpt4 book ai didi

java - 如何区分 ehcache 中的生存时间和空闲时间

转载 作者:IT老高 更新时间:2023-10-28 11:28:36 24 4
gpt4 key购买 nike

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.

我了解timeToIdleSeconds

但这是否意味着在创建和首次访问缓存项后,timeToLiveSeconds 不再适用?

最佳答案

timeToIdleSeconds 允许缓存对象被保留,只要它在短于 timeToIdleSeconds 的周期内被请求。 timeToLiveSeconds 将使缓存的对象在该秒后失效,无论它被请求多少次或何时被请求。

假设 timeToIdleSeconds = 3。那么这个对象在4秒内没有被请求就会失效。

如果 timeToLiveSeconds = 90,则该对象将在 90 秒后从缓存中删除,即使它在其短暂生命的第 90 秒内被请求了几毫秒。

关于java - 如何区分 ehcache 中的生存时间和空闲时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2583429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com