0

I have an application which already written in Hibernate and is mapped to hiberante database annotations (and in the background I am using Postgres as DB). I was wondering if there is a way to keep the database as is, but to add another level of "database" which holds everything In-Memory in java object?

What I mean is, 1) keep Postgres update when there is update/delete/create and only return after it is really commited.

2) when some DB Read queries executed, I want to be able to return the answer using my java object And avoid calling the database for those Read operations

1

1 Answer 1

1

Hibernate has an awesome feature built in called a second level cache. This will allow you to "plugin" a caching system like ehcache to offload a lot of the database read load. Ehcache can either be used standalone or in a distributed manor. Ehcache on its own is a very powerful tool that you can also leverage in front of webservice calls and other lookups as well. I will post a few decent reading links for you.

http://howtodoinjava.com/hibernate/hibernate-ehcache-configuration-tutorial/

http://www.mkyong.com/ehcache/ehcache-hello-world-example/

You can also consider using spring with ehcache for a more declarative caching style if you want to use it standalone

http://www.mkyong.com/spring/spring-caching-and-ehcache-example/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.