使 EHCache 使未以特定方式访问过的元素过期

发布于 2024-11-09 14:01:44 字数 787 浏览 0 评论 0原文

我试图让 EHCache 将缓存元素标记为过期(如果在指定时间内未以特定方式访问它们)。

我有一个自动缓存刷新器,它应该刷新缓存中的元素而不更新上次访问时间。它按正常时间表运行。但是,如果用户通过应用程序从缓存中请求某些内容,则应更新上次访问时间。用户不活动一周后,元素应该过期并从缓存中删除。

EHCache 是否已经有任何可以解决此类问题的东西?我看到 putQuietgetQuiet 方法,但我没有看到任何明确提及它们不更新上次访问时间的信息。另外, timeToLiveSecondstimeToIdleSeconds 参数?

谢谢, 麦克风

I'm trying to get EHCache to mark cache elements as expired if they have not been accessed in a particular way, within a specified amount of time.

I have an automated cache-refresher which should refresh elements in the cache without updating the last-accessed time. It runs on a regular schedule. However, if a user requests something from the cache through the application, then the last-accessed time should be updated. Elements should expire and be removed from the cache after a week of user inactivity.

Does EHCache have anything already in-place that would solve this sort of problem? I see the putQuiet and getQuiet methods, but I don't see any explicit mention of them not updating the last-accessed time. Also, is there any real difference between the timeToLiveSeconds and timeToIdleSeconds parameters?

Thanks,
Mike

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

污味仙女 2024-11-16 14:01:44
 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.

对于其他属性,请参阅 ehcache 包附带的 ehcache.xml。您可以使用 缓存构造函数 以及参数,然后缓存将自行管理

 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.

for other attributes refer the ehcache.xml that ships with the ehcache package. you can instantiate your cache with the Cache construtor with the parameters then the cache will manage this on its own

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文