Fine-grained caching lets you cache a data subset, such as information that does not frequently change. Fine-grained caching is at the function level, because a function's role is to retrieve specific information.
Objectives
After completing this lesson, you will be able to:
Define a cache policy for the slow credit rating Web service.
Testing caching performance.
Overview
ALDSP provides a flexible caching mechanism to manage caching of data service functions. In Part 1, you learned how to cache a function in a logical data service. However, there are situations where you may want to cache only a sub-set of information available in a particular logical data service. For example, the CustomerProfile data service includes information about each customer's profile and order information. The profile information does not change often, whereas order information constantly changes. In this situation users would like to cache the profile information for a given customer but retrieve the most recent order information from the operational system.
By defining different caching policies for the underlying customer and order physical data services, you can cache only the CUSTOMER physical data service. As a result, any request made to the logical CustomerProfile data service will be partly answered from the ALDSP Cache for customer information and partly answered from the operational system for order information.
29.1 Enabling Function-Level Caching for a Physical Data Service
Caching of a function in an underlying data service provides you with the ability to cache a sub-set of data within a data service function.
Objectives
In this exercise, you will:
Enable application-level caching and function-level caching.
Instructions
Login to the ALDSP Console (http://localhost:7001/ldconsole/), using the following credentials:
User Name = weblogic
Password = weblogic
Using the + icon, expand the ldplatform directory.
Note:
If you click the ldplatform name, the Application List page opens. This is not the page you want for this lesson.
Click Evaluation. The Administration Control's General page opens.
In the Data Cache section, select Enable Data Cache.
Select cgDataSource from the Data Cache data source name drop-down list.
Enter WSCACHE in the Data Cache table name field.
Click Apply.
Figure 29-1 Enable Caching
Expand the Evaluation folder and navigate to getCreditRatingResponse.ds, located in DataServices\WebServices folder.
For the getCreditRating() function, set a caching policy by completing the following steps:
Select Enable Data Cache.
Enter 300 in the TTL field.
Click Apply.
Figure 29-2 Enable Function-Level Caching
29.2 Testing the Caching Policy
You are now ready to test your new fine-grained caching policy.
Objectives
In this exercise, you will:
Test the function-level caching policy.
Determine whether the cache was populated.
Instructions
In WebLogic Workshop, execute a test query by completing the following steps:
Open CustomerProfile.ds in Test View. The file is located in the CustomerManagement folder.
Select getCustomerProfile(CustomerID) from the function drop-down list.
Enter CUSTOMER3 in the Parameter field.
Click Execute.
In the Output window, note the number of invocations and the times for the NewLookupCreditResponse and getCreditRatingResponse data sources.
In the PointBase Console, check whether the cache database table was populated by completing the following steps:
Start the PointBase Console, using the following command in a command prompt window:
Click Execute to check whether the cache was populated.
Figure 29-3 PointBase Console Cache Information
29.3 Testing Performance Impact
The next step is to determine whether the caching policy improves query performance.
Objectives
In this exercise, you will:
Execute a data service test.
Determine whether the caching policy improved query performance time.
Instructions
In WebLogic Workshop, execute a test query by completing the following steps:
Open CustomerProfile.ds in Test View. (The file is located in the CustomerManagement folder.)
Select getCustomerProfile() from the function drop-down list.
Enter CUSTOMER3 in the Parameter field.
Click Execute.
Confirm the following performance results in the Output window:
Confirm that the slow Web service (NewLookupCreditRatingResponse) was never invoked due to alternate path execution.
Determine whether caching the Web service helped to reduce the query execution time.
Lesson Summary
In this lesson, you learned how to:
Enable the cache for a physical data service function and define the cache's TTL.
Determine the performance impact of the physical data service cache on a function in a logical data service by checking the query response time and whether the physical data service (original data source) was invoked.