Skip Headers

# Cache Invalidation API

Previous

Next

You configure cache invalidation using `Descriptor` methods `getCacheInvalidationPolicy` and `setCacheInvalidationPolicy` to configure an `oracle.toplink.descriptors.invalidation.CacheInvalidationPolicy`.

You can use any of the following `CacheInvalidationPolicy` instances:

- `DailyCacheInvalidationPolicy`: The object is automatically flagged as invalid at a specified time of day.

- `NoExpiryCacheInvalidationPolicy`: The object can only be flagged as invalid by explicitly calling `oracle.toplink.sessions.IdentityMapAccessor` method `invalidateObject`.

- `TimeToLiveCacheInvalidationPolicy`: The object is automatically flagged as invalid after a specified time period has elapsed since the object was read.

You can also configure cache invalidation using a variety of API calls accessible through the `Session`. The `oracle.toplink.sessions.IdentityMapAccessor` provides the following methods:

- `getRemainingValidTime`: Returns the remaining life of the specified object. This time represents the difference between the next expiry time of the object and its read time.

- `invalidateAll`: Sets all objects for all classes to be invalid in TopLink identity maps.

- `invalidateClass(Class klass)` and `invalidateClass(Class klass, boolean recurse)`: Set all objects of a specified class to be invalid in TopLink identity maps.

- `invalidateObject(Object object)`, `invalidateObject(Record rowWithPrimaryKey, Class klass)` and `invalidateObject(Vector primaryKey, Class klass)`: Set an object to be invalid in TopLink identity maps.

- `invalidateObjects(Expression selectionCriteria)` and `invalidateObjects(Vector collection)`: Set all objects from the specified Expression/collection to be invalid in TopLink identity maps.

- `isValid(DatabaseRow rowContainingPrimaryKey, Class theClass)`, `isValid(Object object)` and `isValid(java.util.Vector primaryKey, Class theClass)`: Return `true` if the object is valid in TopLink identity maps.

For more information, see the following:

- "Configuring Cache Expiration at the Project Level"

- "Configuring Cache Expiration at the Descriptor Level"

- "Configuring Cache Expiration at the Query Level"