Caching

This table lists the Caching information fields available in the JPA Details view for each entity type.

Property Description Default Available for Entity Type

Cachable

Specifies if the entity is cachable.

This field corresponds to the @Cachable annotation.

True

Entity and Mapped superclass

Type

Select one of the following as the Default Cache Type:

  • Weak with Soft Subcache–This option is similar to Weak with Hard Subcache except that it maintains a most frequently used subcache that uses soft references. The size of the subcache is proportional to the size of the identity map. The subcache uses soft references to ensure that these objects are garbage-collected only if the system is low on memory.

    Use this identity map in most circumstances as a means to control memory used by the cache.

  • Weak with Hard Subcache–This option is similar to Soft with Weak subcache except that it maintains a most frequently used subcache that uses hard references. Use this identity map if soft references are not suitable for your platform.

  • Weak–This option is similar to Full, except that objects are referenced using weak references. This option uses less memory than Full, allows complete garbage collection and provides full caching and guaranteed identity.

    Use this identity map for transactions that, once started, stay on the server side.

  • Soft–This option is similar to Weak except that the map holds the objects using soft references. This identity map enables full garbage collection when memory is low. It provides full caching and guaranteed identity.

  • Full–This option provides full caching and guaranteed identity: all objects are cached and not removed.

    Note: This process may be memory-intensive when many objects are read.

  • None–This option does not preserve object identity and does not cache objects.This option is not recommended.

Weak with Soft Subcache

Entity and Mapped superclass

Size

Defines the size of cache to use (number of objects).

100

Entity and Mapped superclass

Advanced



Entity and Mapped superclass

Expiry

Enables the expiration of the cached instance after a fixed period of time (milliseconds). Queries executed against the cache after this will be forced back to the database for a refreshed copy.

No expiry

Entity and Mapped superclass

Always refresh

Specifies if all queries that go to the database should always refresh the cache.

False

Entity and Mapped superclass

Refresh only if newer

Specifies if all queries that go to the database should refresh the cache only if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field).

Notes:

  • This option only applies if one of the other refreshing options, such as alwaysRefresh, is already enabled.

  • A version field is necessary to apply this feature.

False

Entity and Mapped superclass

Disable hits

Specifies if all queries should bypass the cache for hits, but still resolve against the cache for identity. This forces all queries to hit the database.

False

Entity and Mapped superclass

Coordination type

Specify the cache coordination mode:

  • Send Object Changes

  • Invalidate Changed Objects

  • Send New Objects with Changes

  • None

Send Object Changes

Entity and Mapped superclass

Existence checking

Specify how Dali should check to determine if an entity is new or exists.

  • Check Cache – If the object's primary key does not include null and it is in the cache, then it must exist.

  • Check Cache then Database – Perform a "does exist check" on the database.

  • Assume Existence – If the object's primary key does not include null then it must exist. You may use this option if the application guarantees or does not care about the existence check.

  • Assume Non-existence – Assume that the object does not exist. You may use this option if the application guarantees or does not care about the existence check. This will always force an INSERT operation.

Check Cache then Database

Entity and Mapped superclass


Related reference