-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: EHCache and Hibnernate Question
PostPosted: Wed Oct 19, 2011 9:10 am 
Newbie

Joined: Wed Oct 19, 2011 9:07 am
Posts: 1
I have a scenario where i am displaying the data in the database which changes frequently (changed by outside application)on a webpage using spring mvc, somewhat similar to a stock monitoring application. Currently i am using a daemon thread which fires on web container startup and queries the database every 45 secs and stores the data in the application wide hashmap object. And the web application reads the data from hashmap (instead of database) for displaying the data.

I have read about third party caching API's like EHCache and OSCACHE. I have read the documentation on EHCACHE and seems like i can use the hibnernate query caching technique instead of a daemon thread.

Now my question if i use hibernate and enable query caching and set timetoidle to 45 secs will the data in the cache is automatically refreshed to reflect latest data in the database or do i need force refresh (query the database again and repopulate the cache )the cache? Also can you explain what a self populating cache is?


Top
 Profile  
 
 Post subject: Re: EHCache and Hibnernate Question
PostPosted: Fri Oct 21, 2011 8:40 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Now my question if i use hibernate and enable query caching and set timetoidle to 45 secs will the data in the cache is automatically refreshed to reflect latest data in the database?


No the data in the cache is not automatically refreshed in that moment.
You need to call the query again,
the cache recognizes that the cache entries are evicted, so the query is again executed against the database.
This repopulates the cache, so for the next 45 secs the query is cached again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.