我要做的是为缓存设置TTL(生存时间)和TTI(空闲时间),以便键在TTL时间后过期,或者在TTI期间没有被访问时可以提前过期。在Ehcache 2中,可以通过以下配置实现:
在Ehcache 3中,类似的配置块如下所示:
问题在于这样的配置被认为是无效的,因为 ehcache.xsd 规定,在
<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
,但不能同时存在)。