Skip Headers

# Configuring Cache Refreshing

Previous

Next

By default, TopLink caches objects read from a data source (see Understanding the Cache). Subsequent queries for these objects will access the cache and thus improve performance by reducing data source access and avoiding the cost of rebuilding object's and their relationships. Even if a query, such as a read-all query, accesses the data source, if the objects corresponding to the records returned are in the cache, TopLink will use the cache objects.

This can lead to stale data in the application. Although using an appropriate locking policy (see "Configuring Locking Policy") is the only way to ensure that stale or conflicting data does not get committed to the data source, sometimes certain data in the application changes so frequently that it is desirable to always refresh the data, instead of only refreshing the data when a conflict is detected.

You can specify how the TopLink runtime handles cache refreshing for all queries on a descriptor's reference class.

Table: Descriptor Support for Read Only summarizes which descriptors support query cache refresh configuration.

Descriptor Support for Query Cache Refresh

Descriptor | Using TopLink Workbench | Using Java
--- | --- | ---
Relational DescriptorsFoot 1 |  |
Object-Relational Descriptors |  |
EIS DescriptorFoot 2 |  |
XML Descriptors |  |

Footnote 1 Relational class descriptors only (see "Relational Class Descriptors").

Footnote 2 EIS root descriptors only (see "EIS Root Descriptors").

Configuring descriptor-level cache refresh may affect performance. As an alternative, consider configuring the following:

- cache refresh on a query-by-query basis (see "Refreshing the Cache")

- cache expiration (see "Configuring Cache Expiration at the Descriptor Level")

- isolated caching (see "Cache Isolation")

For more information, see "Cache Optimization".