上ehache的文檔說:如何生存時間和時間之間的區別在了Ehcache閒置
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不適用了?
因此,我認爲我們總是希望設置閒置時間
2010-04-21 03:41:58
在上面的註釋中,當您說「讓我們說timeToIdleSeconds = 3.如果對象在4秒內未被請求,則對象將失效」。說無效 - 這是什麼意思?它是否將其從堆中刪除? 如果從緩存中刪除對象,那麼我對使用timeToLive參數有什麼困惑。 當我們做了POC時,我們看到數據是在時間之後從擷取到閏秒。雖然timetoLive的值更高,但我預料它會從緩存中獲取,因爲timetoLive的值比timeToIdle高得多。 – Gayathri 2011-01-30 16:45:53
@Gayathri如果你有一個經常訪問的數據項(每兩秒),但TTL爲60秒。即使連續訪問(從不閒置),它仍會每六十秒從源頭中取出一次。 – 2013-03-01 14:38:30