Transactions pass in a timestamp indicating transaction start time which is then used to protect against concurrent access. Exactly how that happens is based on the actual access-strategy implementation used.
Two different implementation patterns are provided for:
- A transaction-aware cache implementation might be wrapped by a synchronous access strategy, where updates to the cache are written to the cache inside the transaction.
- A non-transaction-aware cache would be wrapped by an asynchronous access strategy, where items are merely "soft locked" during the transaction and then updated during the "after transaction completion" phase. The soft lock is not an actual lock on the database row, it only prevents access to the cached representation of the item.
- for an asynchronous cache, cache invalidation must be a two-step process ("lock" then "unlock", or "lock" then "after update"), since this is the only way to guarantee consistency with the database for a non-transactional cache implementation, but
- for a synchronous cache, cache invalidation may be performed in a single operation ("evict" or "update").
CollectionDataAccessdefine a three-step process to allow for both models (see the individual contracts for details).
Note that query result caching does not go through an access strategy; those caches are managed directly against
Interface Summary Interface Description CachedDomainDataAccessBase contract for accessing the underlying cached data for a particular Navigable of the user's domain model in a transactionally ACID manner. CollectionDataAccessContract for managing transactional and concurrent access to cached collection data. EntityDataAccessContract for managing transactional and concurrent access to cached entity data. NaturalIdDataAccessContract for managing transactional and concurrent access to cached naturalId data. SoftLockMemento object for use by synchronous concurrency strategies
Enum Summary Enum Description AccessTypeEnumerates the policies for managing concurrent access to the shared second-level cache.
Exception Summary Exception Description UnknownAccessTypeExceptionIndicates that an unknown AccessType external name was encountered or that an AccessType was requested that the underlying cache provider does not support.