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 read_committed_verify_updates
or read_committed_with_cache_verify_updates
.
See “Configuring CMP isolation level”.
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) EAServer uses OCC verification queries when you specify an
isolation level that includes verify
in
the name. At commit time, the verification query checks whether
the data has changed since it was originally selected. You should not
disable OCC when using object caching, and you should use a timestamp
column rather than using the default value-comparison technique
of concurrency control. For details on configuring the timestamp
column, see “Configuring OCC options”.
Read consistency using timeouts and synchronization For applications that have a more lax requirement for read consistency, you can configure cache timeouts and synchronization 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. You can also configure your database to notify the cache manager of updates, inserts, and deletes. Doing so allows EAServer to refresh the cache contents after data is modified by another application. See “Enabling database change notification” for more information. The same notification technique is used for both object caching and query caching.
In addition, if the component is deployed in a cluster, you can configure inter-server synchronization, which uses the EAServer message service to replicate data changes between servers in the cluster. This ensures that all caches have the same data. To use this option, configure the Cache Synchronization property described in “Configuring object caching”.
Copyright © 2005. Sybase Inc. All rights reserved. |