This chapter describes how to set up and manage caching for data services in Oracle Data Service Integrator. It contains the following sections:
|Note:||Caching is not available for ad-hoc queries and XQuery functions for security.|
By caching data returned by data service functions, you can improve response times for clients and reduce the processing burden on back-end systems.
|Note:||When results sets are cached, there are chances of using stale data instead of the updated information.|
To use results caching, a database that is certified for Oracle Data Service Integrator caching support should be installed and running. Such DBMS systems are identified in the.
You can specify if you want to enable caching for functions in the Workshop for WebLogic Overview mode. When you run the function the first time, the query results for the function are saved to a local query results cache. The next time the function is run with the same parameters, Oracle Data Service Integrator checks the cache configuration and, if the results have not expired, retrieves the results from the cache rather than from the external source.
A cache entry exists for the results of each function invocation with distinct parameters. In cases when a cache-enabled function is invoked twice with two different parameters, two cache entries will be created.
By default caching is disabled. If you enable it, you can configure the cache and its time-to-live (TTL) for individual data service functions through the Oracle Data Service Integrator Administration Console.
To enable caching for data service functions, you need to:
The TTL setting is set individually for each data service function. In general, the more dynamic the underlying data, the more frequently the cache should be set to expire.
|Note:||Cached data is valid until the TTL limit goes past the time at which it is cached regardless of other changes in the configuration between that time.|
In some cases, caching should not be used at all. Here are two examples:
If an Oracle Data Service Integrator-enabled server shutdown occurs, the contents of the results cache are retained. When the server restarts, it resumes caching as before. On first invocation of a cache-enabled function, the Oracle Data Service Integrator-enabled server checks the results cache to determine whether the cached results for this function are valid or have expired, and then proceeds accordingly.
Oracle Data Service Integrator provides an API allowing client applications to bypass any existing cached results in favor of the physical data source. This API provides automatic client-side cache refresh of the affected function. For details about forcing data cache update and read-through, refer to “Forcing Data Cache Read-through and Update” in thechapter. Application Developer’s Guide:
|Note:||Caching is particularly effective in cases when significant processing has been applied against large data sets, producing filtered results. For optimal performance, it is recommended that you not enable caching on functions that simply return large data sets directly from a relational database data source.|
Oracle Data Service Integrator can set up the cache table in the data source for you (if the server is in development mode), or you can create it yourself as described in the following section. Note that it is recommended that the dataspace not share cache tables. There should be separate tables for each dataspace.
|Note:||To prevent unauthorized access to sensitive data in the cache, it is important to maintain access control over the cache database. Also, make sure that the JDBC data source used for caching is not be used for other purposes.|
The steps for setting up cache depend on several factors, including whether you are in development or production mode and whether you need to customize the cache table schema. Figure 8-1 shows the steps for setting up caching.
The steps illustrated in Figure 8-1 are described in the following sections:
For a WebLogic server that is in development mode, you can set up the cache table automatically from the Oracle Data Service Integrator Administration Console using the data source you choose. For production environments, or if you want to customize the cache schema, you will need to run the SQL scripts manually.
You can create the cache table using SQL scripts in the subdirectory corresponding to a particular DBMS at the following location:
To create the cache table:
You should not change the column names or otherwise modify the structure of the schema tables (except in specific cases, as noted in ). See Table 8-1 for information about the cache table schema.
When the table is created automatically by Oracle Data Service Integrator (as described in), an index for CHASH is created. The automatically created name is the table name with "_INDEX" appended to it.
|Note:||On DB2, the name is truncated to a maximum of 18 characters.|
Oracle Data Service Integrator requires that its cache tables have a specific schema. Therefore, you should generally not modify the structure of the cache table. In some cases, however, the default column sizes may need to be adjusted based on the deployment. This may be a requirement in cases when you have data services that frequently serve result sets that are larger than the content columns in the default database tables and you are using DB2 as your DBMS.
For DB2, the scripts create the CINVKEY and CCONTENT columns (which store the results data) with a specific size, as shown in Table 8-1. If any serialized keys or content need to be larger than that size, the table schema should be adjusted accordingly before running the script.
Before attempting to implement customizations to the cache table, you should be familiar with the schema as shown in Table 8-1.
After creating the cache table, you can use the WebLogic Server Administration Console to create a JDBC data source on the WebLogic Server that points to the database that you have set up for the Oracle Data Service Integrator cache.
|Note:||If using Oracle as your cache database, you must set the Honor Global Transactions setting to
Once created, you can enable the result cache as described in the following section.
After configuring the table that you want to use for caching as a JDBC data source in the WebLogic Server Administration Console, you can set up the cache tables using the Oracle Data Service Integrator Administration Console.
To specify the cache database and enable caching:
Once caching is enabled, you need to configure results caching for each function.
After enabling Cache settings for the dataspace, you can configure data service function caching. For each function, you can specify whether caching should be enabled, and set the time-to-live (in seconds) for cache entries.
To enable caching by function:
The Data Cache page appears, as illustrated in Figure 8-3.
|Note:||Make sure that you set the Allow Data Caching property for the function to true in Oracle Data Service Integrator IDE, before enabling data caching on the console. For example, to enable caching for ADDRESS(), set Allows Data Caching property to true in Oracle Data Service Integrator IDE, as shown in Figure 8-4.|
This features provides the ability to filter cached entries based on user profile. When you select the Add Identity Keys in Cache checkbox, the data cache values become user-specific, which ensures that relevant data cache entries are available to the corresponding user. For example, if two users, User A and User B, are accessing the cached values for functions, then User A will be able to view values specific to User A’s transactions and User B will be able to view cached values for transactions done by User B.
This feature is especially useful when an external data source is mapped and managed through Oracle Data Service Integrator Administration Console.
You can manage function-level data caching using the Operations category. Selecting the Operation category displays the Monitor tab as shown in Figure 8-5.
This tab provides runtime cache statistics for functions and allows you purge the cache.
The Number of Data Cache Entries field displays the number of results that have been cached in the data cache.
|Note:||The Operations category pertains to the runtime monitoring of deployed artifacts. In other words, the Operations category depends on the core (deployed) session. By contrast, other categories such as Service Explorer and Security relate to the session in progress.|
Purging the cache removes cached entries from the cache database. When the cache is purged, each function executes against its data sources until it is cached again.
Oracle Data Service Integrator flushes the cached query result for a given stored query whenever any of the following events occur:
Oracle Data Service Integrator flushes the cached function result on the next invocation whenever any of the following events occur:
You can also purge the cache manually, either for the entire dataspace at once, or for individual functions, as described in the following sections.
To purge the cache for a dataspace:
You can purge the cache for individual functions using the Monitor tab in the Operations category, as illustrated in Figure 8-5.
To purge cache by function: