使用 EhCache 禁用特定的缓存元素



我正在为 ehcache 使用 xml 配置,如下所示:-

<ehcache>
<cache name="ThumbnailCache" maxElementsInMemory="100" maxElementsOnDisk="100" eternal="false" timeToIdleSeconds="100" timeToLiveSeconds="100" overflowToDisk="true" diskPersistent="false"
    memoryStoreEvictionPolicy="LFU" />
<cache name="PDFCache" maxElementsInMemory="100" maxElementsOnDisk="100" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="1800" overflowToDisk="true" diskPersistent="false"
    memoryStoreEvictionPolicy="LFU" />
</ehcache>

现在我想禁用PDFCache,而不是缩略图缓存。我如何实现这一点?我所看到的方式禁用了整个ehcache,我不想禁用整个ehCaching。

您可以通过调用 net.sf.ehcache.Cache#setDisabled 来禁用缓存。执行此操作的可能性由dynamicConfig控制,默认情况下处于启用状态。

最新更新