File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes cache expensive data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "cache expensive data" Watch "cache expensive data" New topic

cache expensive data

John Molitor
Ranch Hand

Joined: Nov 08, 2004
Posts: 39
I have an application that has 4 servers total on two different boxes. I need to get a list of data from another system via remote EJB. It is too expensive to call this EJB over and over again. I would like to cache the data, but the data is not static, so if cached I would need to expire the cache on all 4 servers when the data changes. Any suggestions?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sounds like you're stuck with the best reason to cache - expensive calls - and the best reason not to - data changes.

Can you get the other server to tell you when the data goes stale? JMS pub-sub is good for that. Or make an inexpensive call to ask it?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

How up to date does the data need to be. On a frequently used system, expiring the cache after a minute (or X seconds) will still yield some improvement.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
John Molitor
Ranch Hand

Joined: Nov 08, 2004
Posts: 39
I might be able to get away with the flagging the data as expired after an hour. That would help I'm sure. It sounds like there isn't really a great way to do it. I was also considering a view of data in my schema to the other schema, but I would rather not do that.
I agree. Here's the link:
subject: cache expensive data
It's not a secret anymore!