It's not a secret anymore!*
The moose likes EhCache and the fly likes Query Cacheing using EHCACHE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Caching » EhCache
Bookmark "Query Cacheing using EHCACHE" Watch "Query Cacheing using EHCACHE" New topic
Author

Query Cacheing using EHCACHE

Chandra Sarat
Greenhorn

Joined: Oct 18, 2011
Posts: 1
Hello,

I have a use case 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?


Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

You have to set 2 properties:-

timeToIdleSeconds:
Sets the time to idle for an element before it expires.
i.e. The maximum amount of time between accesses before an element expires
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that an Element can idle for infinity.
The default value is 0.

timeToLiveSeconds:
Sets the time to live for an element before it expires.
i.e. The maximum time between creation time and when an element expires.
Is only used if the element is not eternal.
Optional attribute. A value of 0 means that and Element can live for infinity.
The default value is 0.


===Vyas Sanzgiri===
My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query Cacheing using EHCACHE