It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Data caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Data caching" Watch "Data caching" New topic

Data caching

Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Always we talk about caching the data, fetched from the database. Suppose an user retrieves set of records matching his search criteria, if we cache the data, we can use the cache data provided, the same user or another user fires a same search criteria.So unless iam not sure of same search criteria, its of waste for me to cache the data. I just want to know whether my understanding is correct or wrong. If this "understanding is wrong" can any one please provide explaination links to caching.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Originally posted by Hari babu:
...So unless iam not sure of same search criteria, its of waste for me to cache the data.

Wait. Even if search criteria is the same, can't the results be different? What if the underlying data has been updated since the first search by another user?
Entity beans provides pessimistic caching and if you are using them, you are already making use of caching. If you like to design your own caching framework, consider some of the challenges -
The instance you cache any data, you accept the risk of working with "stale" data. A cache that cannot be updated is useless. But the question is, how frequently should you update the cache? And should you cache mostly dynamic data, or mostly static data? If the cost of maintaining the cache upto date outweighs the benefits of caching, then is it worth in the first place?
IMO you should first attempt to answer these questions in the context of your application.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I agree. Here's the link:
subject: Data caching
It's not a secret anymore!