user3620177
user3620177

Reputation: 1

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?

Upvotes: 0

Views: 1296

Answers (1)

Arunas Junevicius
Arunas Junevicius

Reputation: 747

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.

Upvotes: 1

Related Questions