• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Avoid stale data in In-memory ?

 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In-memory sits between Web Server and Repository server for better performance. Also, sets time-to-live as 300 seconds for pooling from DB server to in-memory. How to get the latest data from DB using J2EE application, if data changed in repository server before 300 seconds pooling,
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have control over the process updating the database? If so, you can invalidate the data in the cache/in memory version.
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not have control over the process updating the database
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't control the other end, all you can do is poll more frequently. In other words, you can set it to poll every 60 seconds instead of 300 seconds on find out 5 times faster that the data has changed. There is always the chance of stale data with this approach. You have to figure out at what level that becomes acceptable. And if the load makes it worth caching. I worked on one system with a 15 second cache for one piece of data. That data was requested enough that even this tiny cache increased performance.
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is always the chance of stale data using polling process in un control over the process updating the database process. What is the best way for control over the process updating the database process ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can change the process, you would add code to the database process to send a message remotely to your system that it should invalidate the cache. Whether this is worth it depends on the frequency of data changes vs the length of the cache.
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i use combination of both ie: polling (from cache ) and event/listener approach(listener will listen the events) ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need both. If polling is acceptable as a solution, it works on its own.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic