Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring Cache Expiration at the Descriptor Level

By default, objects remain in the cache until they are explicitly deleted (see "Deleting Objects") or garbage collected when using a weak identity map (see "Configuring Cache Isolation at the Project Level"). Alternatively, you can configure an object with a `CacheInvalidationPolicy` that allows you to specify, either automatically or manually, that an object is invalid: when any query attempts to read an invalid object, TopLink will go to the data source for the most up-to-date version of that object and update the cache with this information.

Using cache invalidation ensures that your application does not use stale data. It provides a better performing alternative to always refreshing (see "Configuring Cache Refreshing").

Table 28-16 summarizes which descriptors support a cache invalidation policy.

Table 28-16 Descriptor Support for Cache Invalidation Policy

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

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

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

You can override the project-level cache invalidation configuration (see "Configuring Cache Expiration at the Project Level") by defining cache invalidation at the descriptor or query level (see "Configuring Cache Expiration at the Query Level").

You can customize how TopLink communicates the fact that an object has been declared invalid to improve efficiency, if you are using a coordinated cache. For more information, see "Configuring Cache Coordination Change Propagation at the Descriptor Level".

For more information, see "Cache Invalidation"

## Using TopLink Workbench

To specify the cache invalidation information for a descriptor, use this procedure:

1. Select the descriptor in the Navigator.

2. Select the Caching tab in the Editor. The Caching tab appears.

   Figure 28-28 Caching Tab, Expiration Options

   Description of "Figure 28-28 Caching Tab, Expiration Options"

Use this table to enter data in the following fields on the Caching tab to specify the cache invalidation policy for the descriptors.

Field | Description
--- | ---
Project Default | Use the project's cache expiration options for this descriptor. See "Configuring Cache Expiration at the Project Level" for more information.
No Expiry | Specify that objects in the cache do not expire.
Time to Live Expiry | Specify that objects in the cache will expire after a specified amount of time. Use the Expire After field to indicate the time (in milliseconds) after which the objects will expire.
Daily Expiry | Specify that objects in the cache will expire at a specific time each day. Use the Expire At field to indicate the exact time to the second (using a 24-hour clock) at which the objects will expire.
Update Read Time on Update | Specify if TopLink should reset the cached object's expiry time after the TopLink successfully updates the object.

## Using Java

Use `ClassDescriptor` method `setCacheInvalidationPolicy` to set an appropriate instance of `CacheInvalidationPolicy`.