Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
786 views
in Technique[技术] by (71.8m points)

java - ehcache not expiring elements from diskstore

I want to cache elements only in the diskstore not in memory/ram, for this i have used following configuration, it stores the elements on disk but it doesn't expire/remove data from disk after 5 minutes.

<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" />

What i can do in the ehcache configuration which will expire elements from diskstore after specified time?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can't, as documentation states:

If an entry expires but is not accessed, and no resource constraints force eviction, then the expired entry remains in place.

And even if some constraint would force eviction Ehcache might remove only part of expired entry, so that it would not need to scan all the disk store. If you absolutely need to keep track of every entry that's expired you'll have to implement this functionality your self, but that would hit your performance. Probably that's the reason this functionality isn't builtin in Ehcache.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...