Page 2 of 5
To discern the source of the performance degradation, you use a profiling product and discover that the server loads multiple
copies of database ResultSets, each of which has several thousand records. The records make up a product list. Moreover, the product list is identical
for every user. The list does not depend on the user, as might have been the case if the product list had resulted from a
parameterized query. You quickly decide that one copy of the list could serve all concurrent users, so you cache it.
However, a number of questions arise, which include such complexities as:
To address these challenges, you need to construct a software caching service.
In the filing cabinet analogy, people always checked the cabinet first when searching for documents. Your software must implement the same procedure: a request must check the caching service before loading a fresh list from the database. As a software developer, your responsibility is to access the cache before accessing the database. If the product list has already loaded into the cache, then you use the cached list, provided it is not expired. If the product list is not in the cache, then you load it from the database and cache it immediately.
Note: Before proceeding to the caching service's requirements and code, you might want to check out the sidebar below, "Caching Versus Pooling." It explains pooling, a related concept.
In keeping with good design principles, I defined a requirements list for the caching service that we will develop in this article:
To satisfy Requirement 1, we adopt a 100 percent pure Java environment. By providing public get and set methods in the caching service, we fulfill Requirements 2 and 3 as well.
Great!By Anonymous on April 30, 2009, 8:40 amvery basic level approach. clean approach for deciding. actually i was chosing between different softwares/caching techniques in market. this article gave me...
Reply | Read entire comment
View all comments