Samples Tutorial

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Managing Data Service Caching

Caching enables the use of previously obtained results for queries that are repeatedly executed with the same parameters. This helps reduce processing time and enhance overall system performance.

 


Objectives

After completing this lesson, you will be able to:

 


Overview

When ALDSP executes a query, it returns to the client the data that resulted from the query execution. If ALDSP caching is enabled, then ALDSP saves its results into a query results cache the first time a query is executed. The next time the query is run with the same parameters, ALDSP checks the cache configuration and, if the results are not expired, quickly retrieves the results from the cache, rather than re-running the query. Using the previously obtained results for queries that are repeatedly executed with the same parameters reduces processing time and enhances overall system performance.

By default, the query results cache is disabled. Once enabled, you can configure the cache for individual stored queries as needed, specifying how long query results are stored in the cache before they expire (time out), and explicitly flushing the query cache.

In general, the results cache should be periodically refreshed to reflect data changes in the underlying data stores. The more dynamic the underlying data, the more frequently the cache should expire. For queries on static data (data that never changes), you can configure the results cache so that it never expires. For extremely dynamic data, you would never enable caching.

If the cache policy expires for a particular query, ALDSP automatically flushes the cache result on the next invocation. In the event of a Server shutdown, the contents of the results cache are retained. On the server restart, the Server resumes caching as before. On the first invocation of a cached query, ALDSP checks the results cache to determine whether the cached results for that query are valid or expired, and then proceeds accordingly.

 


15.1 Determining the Non-Cache Query Execution Time

To understand whether caching improves query execution time, you first need to know how long it takes to execute a non-cached query.

Objectives

In this exercise, you will:

Instructions

  1. Open CustomerProfile.ds in Test View.
  2. Select getCustomerProfile(CustomerID) from the function drop-down menu.
  3. Enter CUSTOMER3 in the Parameter field.
  4. Click Execute. The Output window displays the cache's execution time.
Note: Ensure that auditing is enabled in the ALDSP console, to view results in the Output window. For details about auditing, refer to the Administrator's Guide.
  1. Open the Output window.
  2. Search for query/performance evaltime for the value of query execution time.
  3. Figure 15-1 Query Execution Time


    Query Execution Time

 


15.2 Configuring a Caching Policy Through the ALDSP Console

By default, ALDSP results caching is disabled. You must explicitly enable caching. In this exercise, you will learn how to enable caching.

Objectives

In this exercise, you will:

Instructions

  1. In the ALDSP Console (http://localhost:7001/ldconsole/), using the + icon, expand the ldplatform directory. (Note: If you click the ldplatform name, the Application List page opens. You do not want this page for this lesson.)
  2. Enable caching at the application level, by completing the following steps:
    1. Click Evaluation. The ALDSP Console's General page opens.
    2. In the Data Cache section, select Enable Data Cache.
    3. Select cgDataSource from the Data Cache data source name drop-down list.
    4. Enter MYLDCACHE in the Data Cache table name field.
    5. Click Apply.
    6. Figure 15-2 ALDSP Console General Page


      ALDSP Console General Page

  3. Enable caching at the function level, by completing the following steps (you can cache both logical and physical data service functions):
    1. Open the CustomerProfile folder, located in Evaluation\DataServices\CustomerManagement. The list of data service functions page opens.
    2. For the getCustomerProfile() function, select Enable Cache.
    3. Enter 300 in the TTL (sec) field.
    4. Click Apply.
    5. Note: Application level cache should be enabled.
      Figure 15-3 Setting TTL


      Setting TTL

 


15.3 Testing the Caching Policy

Testing the caching policy helps you determine whether the specified query results are being cached.

Objectives

In this exercise, you will:

Instructions

  1. In WebLogic Workshop, open the CustomerProfile data service in Test View.
  2. Select getCustomerProfile(CustomerID) from the Function drop-down list.
  3. Enter CUSTOMER3 in the Parameter field.
  4. Click Execute.
  5. In the ALDSP Console, verify that the cache is populated by completing the following steps:
    1. Go to the CustomerProfile folder.
    2. Confirm that there are entries in the Number of Cache Entries field for the getCustomerProfile() function.
    3. Figure 15-4 Cache Test Results in the Metadata Browser


      Cache Test Results in the Metadata Browser

 


15.4 Determining Performance Impact of the Caching Policy

A caching policy can reduces processing time and enhance overall system performance.

Objectives

In this exercise, you will:

Instructions

  1. Use the PointBase Console to verify that the cache was populated, by completing the following steps:
    1. Start the PointBase Console, by entering the following command at the command prompt:
    2. $BEA_HOME\weblogic81\common\bin\startPointBaseConsole.cmd
    3. Enter the following configuration parameters to connect to your local PointBase Console:
      • Driver: com.pointbase.jdbc.jdbcUniversalDriver
      • URL: jdbc:pointbase:server://localhost:9093/workshop
      • User: weblogic
      • Password: weblogic
    4. Click OK.
    5. Enter the SQL command SELECT * FROM MYLDCACHE to check whether the cache is populated.
    6. Click Execute.
    7. Figure 15-5 PointBase Console


      PointBase Console

  2. In WebLogic Workshop, open the CustomerProfile data service in Test View.
  3. Select getCustomerProfile(CustomerID) from the Function drop-down menu.
  4. Enter CUSTOMER3 in the Parameter field.
  5. Click Execute. The Output window displays the cache's execution time.
  6. Use the Output window to determine whether caching helped reduce the query execution time.

 


15.5 Disable Caching

Caution: For the purposes of the following lessons, you must disable the cache to avoid problems with data updates.

Objectives

In this exercise, you will:

Instructions

  1. In the ALDSP Console using the + icon, expand the ldplatform directory. (Note: If you click the ldplatform name, the Application List page opens. You do not want this page for this exercise.)
  2. Disable application-level caching, by completing the following steps:
    1. Click Evaluation. The ALDSP Console's General page opens.
    2. In the Data Cache section, clear Enable Data Cache.
    3. Click Apply.
  3. Disable function-level caching, by completing the following steps:
    1. Open the CustomerProfile folder, located in
    2. Evaluation\DataServices\CustomerManagement

      The list of data service functions page opens.

    3. For the getCustomerProfile() function, clear Enable Data Cache.
    4. Click Apply.

 


Lesson Summary

In this lesson, you learned how to:


  Back to Top       Previous  Next