簡體   English   中英

使 EHCache 以特定方式使未被訪問的元素過期

[英]Make EHCache expire elements which have not been accessed in a specific way

我試圖讓 EHCache 將緩存元素標記為已過期,如果它們在指定的時間內沒有以特定方式被訪問。

我有一個自動緩存刷新器,它應該在不更新最后訪問時間的情況下刷新緩存中的元素。 它定期運行。 但是,如果用戶通過應用程序從緩存中請求某些內容,則應更新上次訪問時間。 在用戶不活動一周后,元素應過期並從緩存中刪除。

EHCache 是否已經存在可以解決此類問題的任何東西? 我看到了putQuietgetQuiet方法,但我沒有看到任何明確提及它們沒有更新上次訪問時間。 另外, timeToLiveSecondstimeToIdleSeconds參數之間有什么真正的區別嗎?

謝謝,邁克

 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 package 附帶的 ehcache.xml。 您可以使用帶有參數的緩存構造器實例化緩存,然后緩存將自行管理

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM