public interface OptimisticNamedCache
extends com.tangosol.net.NamedCache
NamedCache
interface that adds support for
optimistic transactions.
Each operation has an associated predicate in the form of a Filter that is used to ensure that the value being updated is the expected value. Update and delete operations have explicit predicates where insert has an implicit predicate. Typically when a value is read and later modified in the scope of a transaction, a predicate is supplied to ensure that the value being modified is the same value that was previously read.
When one of the optimistic operations are invoked, the predicate is applied
to the latest committed value. If the predicate holds, a write lock is
obtained for the row and the value is updated according to the operation.
If the predicate fails a PredicateFailedException
is thrown
back to the caller.
In addition to the PredicateFailedException
, all mutating
operations may throw a UnableToAcquireLockException
if
unable to acquire a write lock.
com.tangosol.net.NamedCache.Option
com.tangosol.util.QueryMap.Entry<K,V>
com.tangosol.util.InvocableMap.Entry<K,V>, com.tangosol.util.InvocableMap.EntryAggregator<K,V,R>, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R>, com.tangosol.util.InvocableMap.ParallelAwareAggregator<K,V,P,R>, com.tangosol.util.InvocableMap.StreamingAggregator<K,V,P,R>
Modifier and Type | Method and Description |
---|---|
void |
delete(Object oKey,
com.tangosol.util.Filter validator)
Delete an existing value.
|
void |
insert(Object oKey,
Object oValue)
Insert a new value.
|
boolean |
lock(Object oKey)
Locking,
ConcurrentMap.lock(Object) , is
currently not available when using a transactional cache. |
boolean |
lock(Object oKey,
long cWait)
Locking,
ConcurrentMap.lock(Object, long) , is
currently not available when using a transactional cache. |
Object |
put(Object oKey,
Object oValue,
long cMillis)
Put with expiry,
NamedCache.put(Object, Object, long) , is
currently not available when using a transactional cache. |
boolean |
unlock(Object oKey)
Unlocking,
ConcurrentMap.unlock(Object) , is
currently not available when using a transactional cache. |
void |
update(Object oKey,
Object oValue,
com.tangosol.util.Filter validator)
Update an existing value.
|
as, async, async, clear, getCacheName, getCacheService, getName, getService, isDestroyed, isReleased, truncate, view
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
containsKey, containsValue, get, isEmpty, put, putAll, remove, size
addIndex, entrySet, entrySet, forEach, forEach, keySet, removeIndex, values, values
aggregate, aggregate, aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invoke, invokeAll, invokeAll, invokeAll, merge, merge, putIfAbsent, remove, replace, replace, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
void update(Object oKey, Object oValue, com.tangosol.util.Filter validator)
oKey
- identifies the entry to updateoValue
- the new valuevalidator
- predicate used to ensure that the value being updated
is the expected value. A null predicate will not
check the current value or even that it exists.com.tangosol.coherence.transaction.exception.PredicateFailedException
- if the predicate failscom.tangosol.coherence.transaction.exception.UnableToAcquireLockException
- if unable to acquire a write lockvoid delete(Object oKey, com.tangosol.util.Filter validator)
oKey
- identifies the entry to deletevalidator
- predicate used to ensure that the value being removed
is the expected value. A null predicate will not
check the current value or even that it exists.com.tangosol.coherence.transaction.exception.PredicateFailedException
- if the predicate failscom.tangosol.coherence.transaction.exception.UnableToAcquireLockException
- if unable to acquire a write lockvoid insert(Object oKey, Object oValue)
oKey
- identifies which row to insertoValue
- the value of the inserted rowcom.tangosol.coherence.transaction.exception.PredicateFailedException
- if the predicate failscom.tangosol.coherence.transaction.exception.UnableToAcquireLockException
- if unable to acquire a write lockObject put(Object oKey, Object oValue, long cMillis)
NamedCache.put(Object, Object, long)
, is
currently not available when using a transactional cache.put
in interface com.tangosol.net.cache.CacheMap
put
in interface com.tangosol.net.NamedCache
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keycMillis
- the number of milliseconds until the cache entry will
expire, also referred to as the entry's "time to live";
pass CacheMap.EXPIRY_DEFAULT
to use the cache's default
time-to-live setting; pass CacheMap.EXPIRY_NEVER
to
indicate that the cache entry should never expire; this
milliseconds value is not a date/time value, such
as is returned from System.currentTimeMillis()UnsupportedOperationException
- alwaysboolean lock(Object oKey, long cWait)
ConcurrentMap.lock(Object, long)
, is
currently not available when using a transactional cache.lock
in interface com.tangosol.util.ConcurrentMap
oKey
- key being lockedcWait
- the number of milliseconds to continue trying to obtain
a lock; pass zero to return immediately; pass -1 to block
the calling thread until the lock could be obtainedUnsupportedOperationException
- alwaysboolean lock(Object oKey)
ConcurrentMap.lock(Object)
, is
currently not available when using a transactional cache.lock
in interface com.tangosol.util.ConcurrentMap
oKey
- key being lockedUnsupportedOperationException
- alwaysboolean unlock(Object oKey)
ConcurrentMap.unlock(Object)
, is
currently not available when using a transactional cache.unlock
in interface com.tangosol.util.ConcurrentMap
oKey
- key being unlockedUnsupportedOperationException
- always