Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ehcache未使diskstore中的元素过期_Java_Ehcache - Fatal编程技术网

Java ehcache未使diskstore中的元素过期

Java ehcache未使diskstore中的元素过期,java,ehcache,Java,Ehcache,我只想将元素缓存在diskstore中,而不是内存/ram中,为此我使用了以下配置,它将元素存储在磁盘上,但不会在5分钟后过期/从磁盘删除数据 <diskStore path="/global-cache" /> <cache name="globalCache" maxElementsInMemory="0" eternal="true" timeToIdleSeconds="0" diskSpoolBuffer

我只想将元素缓存在diskstore中,而不是内存/ram中,为此我使用了以下配置,它将元素存储在磁盘上,但不会在5分钟后过期/从磁盘删除数据

<diskStore path="/global-cache" />

<cache name="globalCache" 
       maxElementsInMemory="0"
       eternal="true" 
       timeToIdleSeconds="0" 
       diskSpoolBufferSizeMB="1"
       diskPersistent="true"
       timeToLiveSeconds="300" 
       diskExpiryThreadIntervalSeconds="120"
       overflowToDisk="true"
       memoryStoreEvictionPolicy="LFU" />

在指定时间后将使diskstore中的元素过期的ehcache配置中,我可以做什么?

您不能,如下所述:

如果条目过期但未被访问,并且没有资源约束 强制驱逐,则过期的条目仍然保留

而且,即使某些约束会强制逐出,Ehcache也可能只删除部分过期条目,这样它就不需要扫描所有磁盘存储。 如果您确实需要跟踪每个过期的条目,您必须自己实现此功能,但这会影响您的性能。这可能就是为什么Ehcache中没有内置此功能的原因