This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Performance and the fly likes Caching solution required to cache the data in memory. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Caching solution required to cache the data in memory." Watch "Caching solution required to cache the data in memory." New topic
Author

Caching solution required to cache the data in memory.

john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 92
Profiling our app has revealed that a significant chunk of time is spent in database calls (all of them are basic select SQLs with differnt attributes). DB trips to fetch the data is ofcourse a performance hit.

Now to avoid this frequent db trips we are planning to keep the entire data in the temporary cache.

Can someone plese point me about any freeware caching solutions provideded that i can use to cache the db data so that i can fetch the data from the cache in a same way
like it is fetched from the DB and which also provides a efficient storage capability.

Moreover the cache that we would be maintaining is not a static cache and data will be added and deleted in it very frequently.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Moreover the cache that we would be maintaining is not a static cache and data will be added and deleted in it very frequently.

How do you avoid your database and cache diverging fairly significantly quite quickly? If the cache is you primary point of data access, should you not abandon the DB altogether and use a caching implementation that has a secondary disk cache? There are loads: EHCache, JCS, OSCache, Terracotta etc.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 92
We are thinking of designing in such a way that data is stored back in the db periodically means we will do batch update of the data stored in the cache.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Then something like Hibernate using a second level cache might be a way to go. You can pull data into the second level cache on demand and flush the cache periodically and the caching is configurable declaratively.

This might not be a solution if you need custom code to handle conflicts in your batch update (i.e. when someone else has updated the database or the cached data diverges from the data model constraints (by accident or design)). That would need to be bespoke.
john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 92
Ya using ORM tool like hibernate is always a better solution for such kind of scenario but unfortunately due to the large migration issues don't have luxury to use the hibernate. As of now we have to either implement it seperately or have to use some external API's for caching the data.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching solution required to cache the data in memory.
 
Similar Threads
about hibernate caching and criteria
Hibernate with RSS Feeds.
hibernate cache
Trying to use cache in my servlets application.
A little issue with <c:set ...>