EHCache problem may occur if system crashes

New for caching ...

I looked in Spring EHCache, and I found its wonderful write-behind function. First, the data is written to the cache, and then to the base database asynchronously, which reduces the load on the database by changing the time, speed limits or merging (by the way, do other caches have the same capabilities?). This is just great for what I need.

Now..

What happens if my server / system / cache crashes badly (I mean really bad) for some reason? Would I lose the data stored in the cache that are waiting to be loaded into the database? Can I prevent this from using "Large memory" or "Disk store", and will these options be convenient?

Thank you very much.

+4
source share
2 answers

Would I lose the [sic] cache data that is waiting to be loaded into the database?

Yes you would. This is a tradeoff that you have to accept with write-behind caches.

If you need transaction integrity, you need to write directly to the transactional backup storage, and then either clear the cache entry ("write back") or update the cache synchronously with the data storage write-through ("write-through").

0
source

All Articles