Encapsulates logic to allow a {@link TransactionalAccessDelegate} to determinewhether a {@link TransactionalAccessDelegate#putFromLoad(Object,Object,long,Object,boolean)}call should be allowed to update the cache. A
putFromLoad
has the potential to store stale data, since the data may have been removed from the database and the cache between the time when the data was read from the database and the actual call to
putFromLoad
.
The expected usage of this class by a thread that read the cache and did not find data is:
- Call {@link #registerPendingPut(Object)}
- Read the database
- Call {@link #acquirePutFromLoadLock(Object)}
- if above returns
false
, the thread should not cache the data; only if above returns true
, put data in the cache and... - then call {@link #releasePutFromLoadLock(Object)}
The expected usage by a thread that is taking an action such that any pending putFromLoad
may have stale data and should not cache it is to either call
- {@link #invalidateKey(Object)} (for a single key invalidation)
- or {@link #invalidateRegion()} (for a general invalidation all pending puts)
This class also supports the concept of "naked puts", which are calls to {@link #acquirePutFromLoadLock(Object)} without a preceding {@link #registerPendingPut(Object)}call.
@author Brian Stansberry
@version $Revision: $