jW.
jW.

Reputation: 9310

Cached data Synchronization to Database

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?

Upvotes: 2

Views: 1379

Answers (1)

ChssPly76
ChssPly76

Reputation: 100766

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.

Upvotes: 3

Related Questions