2
votes

Hello I have a specific task to solve in EhCache, but I am not able to achieve it.

I want to build up a "eternal cache", which will have small amount of items in memory for imminent usage and the rest will be persisted on the disk. I usually write data to cache in multiple threads and want to have those items all the time on the disk so I can use them even after restart.

<cache name="eternal_cache" maxBytesLocalHeap="1%" maxBytesLocalDisk="2G"
       eternal="false" timeToLiveSeconds="0"
       timeToIdleSeconds="120" overflowToDisk="true"
       diskPersistent="true" memoryStoreEvictionPolicy="LFU"
       transactionalMode="off"/>

Basically I want persistence feature in EhCache which is defined via , but with size limitation, which persistence doesn't allow.

I ran into the problem that with my configuration I have items in memory but without proper shutdown ehcache manager loose my data. I read about the flush() but it persist items on the disk, but I want at least some data in memory.

Can you please someone advise me how to configure cache to my needs?

1

1 Answers

2
votes

After reading official manual I have found resolution.

It is possible to persist only using Ehcache Persistence strategy which is however in Enterprise version.

In normal version it's possible only with calling flush() or shutdown().