After the Query Processor executes a query, it returns to the client the data that resulted from query execution. If Liquid Data results caching is enabled, the first time a query is run, Liquid Data saves its results into a query results cache. The next time the query is run with the same parameters, Liquid Data checks the cache configuration and, if the results have not expired, quickly retrieves the results from the cache rather than re-running the query. In this way, for queries that are executed repeatedly with the same parameters, using the results query cache reduces processing time and enhances overall system performance.
The query results cache is disabled by default and must be enabled according to the instructions in Enabling the Results Cache. 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. For more information, see Configuring Results Caching for Stored Queries.
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 be set to expire. For queries on static data, you can configure the results cache so that it never expires.
In the event of a Liquid Data Server shutdown, the contents of the results cache are retained. Upon server restart, the Liquid Data Server resumes caching as before. Upon the first invocation of a cached query, the Liquid Data Server checks the results cache to determine whether the cached results for this query are valid or have expired, and then proceeds accordingly.
Note: The query results cache is stored in a database that you must explicitly configure. For more information, see Setting up the Results Cache Database.
After you have installed and configured a database server, you need to run a SQL script on your database server that creates the Liquid Data cache database. Liquid Data provides the following scripts (in
After you have created the Liquid Data cache database, you need to create a JDBC data source in WebLogic Server that points to the Liquid Data cache database. Using the Administration Console, create a JDBC data source with the following name:
For details about creating a JDBC data source, see Creating a JDBC Data Source.
Note: If you are using Oracle for the cache database, you must set the Honor Global Transactions setting to
FALSE (it is set to
TRUE by default). When you create the Oracle JDBC data source in the WebLogic Administration Console, you must uncheck the Honor Global Transactions box.
Once created, you can enable the result cache, as described in the following section, Enabling the Results Cache
By default, results caching is disabled in Liquid Data. To use results caching, you must explicitly enable it in the General tab on the Liquid Data node in the Administration Console. Before you enable caching, make sure that you have set up the Liquid Data cache database as described in Setting up the Results Cache Database.
Once caching is enabled, you must explicitly configure the results cache according to the instructions in the following section, Configuring Results Caching for Stored Queries.
You can set a security policy on the query cache. The security policy determines if a user can purge results from the cache. The cache security policy is global across the entire cache; that is, if a user has the authority to purge the cache, then that user can purge the cache for any query for which he has access. Depending on the security policy of different queries, the user might have permissions to see some queries and not others.
Table 22-3 describes the different methods you can configure for the cache purging security policy. Set these methods from the Methods drop list on the Define Security Policy page for the cache.
Each stored query has its own cache policy that determines how Liquid Data manages results caching for that stored query. This section describes how to configure the cache policy for stored queries. It includes the following sections:
Note: The expiration time should reflect the degree to which the data in the underlying data source(s) is expected to change. In general, for more dynamic data (such as real-time data feeds), specify a shorter expiration time. For more static data (such as general product or personnel information), specify a longer expiration time.
Note: If you delete a stored query for which caching is enabled, Liquid Data also deletes the cached query plan and any cached results. For more information, see Deleting Folders and Files in the Server Repository.
Flushing the cache is when all of the entries in the cache are purged from the cache. When the cache is flushed, all queries will execute against their data sources until they are cached again. Liquid Data flushes the cached query result for a given stored query whenever any of the following events occur:
You can use the
com.bea.ldi.cache.ejb package to purge the cache programmatically. For details on using the EJB API to purge the cache, see the Using the Cache Purging APIs chapter in the Liquid Data Application Developer's Guide and the Javadoc.