What are the best ways to keep data synchronized between in memory cache and the database when used in a web application? Specifically, I store large amounts of database data in an in-memory cache using EHcache on my web application. For many interactions, I would like to simply modify the value in cache, and only synchronize it with the database during low-traffic times. What is a good way to do this as well to minimize the loss of data should an unexpected shutdown occur?
+3
A:
Are you using some kind of ORM like Hibernate or any other JPA implementation?
If not, perhaps you should - because it does exactly what you want in terms of managing 1st / 2nd level cache and data synchronization with database. Hibernate in particular can use a number of cache providers including the very same EHCache; said cache can be disk-backed or distributed.
ChssPly76
2009-11-06 00:35:11
I am not currently, but it sounds like I should look into it
jW
2009-11-06 01:14:52