When data is maintained in the object cache as well as the source database, you must take steps to ensure these transactional constraints are satisfied:
Read consistency, to ensure that data read from the cache matches data in the source database.
Update consistency, to ensure that updates are not committed if the source data has changed since it was last read.
Read consistency If your application requires read consistency, choose an isolation
level that requires it, such as ReadCommittedVerifyUpdates
or ReadCommittedWithCacheVerifyUpdates
. When
read consistency is required, caching should be used only when the
data changes infrequently. Caching volatile data can make your application
perform worse because the added overhead of retrying queries that
roll back because the data changed.
Update consistency When using caching, transactional update consistency is ensured by:
The timing of cache updates Cache entries are never modified or deleted until the transaction associated with the change has committed.
Optimistic Concurrency Control (OCC) At commit time, EAServer runs a verification query to check whether the data has changed since it was originally selected. If data has been changed by another user, EAServer rolls back the transaction.
You should not disable OCC when using object caching, and you should use a timestamp or version column rather than using the default value-comparison technique of concurrency control. Version columns are preferable to database timestamp columns when using caching. When using the database timestamp column type, EAServer must requery after updates to get the new timestamp value, which partly defeats the advantages of using a cache (particularly if there are frequent updates and you have enabled the cacheLock setting).
Read consistency using timeouts For applications that have a more lax requirement for read consistency, you can configure cache timeouts to minimize the use of stale data. The cache timeout sets a time limit on how long cached data remains valid. Stale entries are refreshed from the source database before the data is used in the component.