我想完成的是爲緩存設置TTL(生存時間)和TTI(時間到空閒),以便密鑰在TTL時間,或者在TTI期間未被訪問的情況下可以提前過期。在Ehcache 3 XML配置中設置TTL和TTI
在的Ehcache 2有可能具有以下配置:
<cache name="my.custom.Cache"
timeToIdleSeconds="10"
timeToLiveSeconds="120">
</cache>
在的Ehcache 3類似的配置塊看起來如下:
<cache alias="my.custom.Cache">
<expiry>
<tti unit="seconds">10</tti>
<ttl unit="minutes">2</ttl>
</expiry>
</cache>
的問題是,這樣的結構被認爲是無效因爲ehcache.xsd指出應該只有一個選項根據expiry
標記(tti
或ttl
,但沒有兩者)。