Skip navigation links
com.tangosol.coherence.transaction
Interface OptimisticNamedCache
- All Superinterfaces:
- CacheMap, ConcurrentMap, InvocableMap, Map, NamedCache, ObservableMap, QueryMap
-
public interface OptimisticNamedCache
- extends NamedCache
An extension to the NamedCache
interface that adds support for optimistic transactions. <p/> 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. <p/> 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. <p/> In additon to the PredicateFailedException
, all mutating operations may throw a UnableToAcquireLockException
if unable to acquire a write lock.
- Since:
- Coherence 3.6
- Author:
- jp, js 2009.2.10
Method Summary |
void |
delete(Object oKey, 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, Filter validator)
Update an existing value. |
update
void update(Object oKey,
Object oValue,
Filter validator)
- Update an existing value.
-
- Parameters:
oKey
- identifies the entry to update
oValue
- the new value
validator
- 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.
- Throws:
PredicateFailedException
- if the predicate fails
UnableToAcquireLockException
- if unable to acquire a write lock
delete
void delete(Object oKey,
Filter validator)
- Delete an existing value.
-
- Parameters:
oKey
- identifies the entry to delete
validator
- 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.
- Throws:
PredicateFailedException
- if the predicate fails
UnableToAcquireLockException
- if unable to acquire a write lock
insert
void insert(Object oKey,
Object oValue)
- Insert a new value. An implicit predicate is associated with the insert operation to ensure that the entry doesn't already exist.
-
- Parameters:
oKey
- identifies which row to insert
oValue
- the value of the inserted row
- Throws:
PredicateFailedException
- if the predicate fails
UnableToAcquireLockException
- if unable to acquire a write lock
put
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.
-
- Specified by:
put
in interface CacheMap
- Specified by:
put
in interface NamedCache
-
- Parameters:
oKey
- key with which the specified value is to be associated
oValue
- value to be associated with the specified key
cMillis
- 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()
- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
- Throws:
UnsupportedOperationException
- always
lock
boolean lock(Object oKey,
long cWait)
- Locking,
ConcurrentMap.lock(Object, long)
, is currently not available when using a transactional cache.
-
- Specified by:
lock
in interface ConcurrentMap
-
- Parameters:
oKey
- key being locked
cWait
- 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 obtained
- Returns:
- true if the item was successfully locked within the specified time; false otherwise
- Throws:
UnsupportedOperationException
- always
lock
boolean lock(Object oKey)
- Locking,
ConcurrentMap.lock(Object)
, is currently not available when using a transactional cache.
-
- Specified by:
lock
in interface ConcurrentMap
-
- Parameters:
oKey
- key being locked
- Returns:
- true if the item was successfully locked; false otherwise
- Throws:
UnsupportedOperationException
- always
unlock
boolean unlock(Object oKey)
- Unlocking,
ConcurrentMap.unlock(Object)
, is currently not available when using a transactional cache.
-
- Specified by:
unlock
in interface ConcurrentMap
-
- Parameters:
oKey
- key being unlocked
- Returns:
- true if the item was successfully unlocked; false otherwise
- Throws:
UnsupportedOperationException
- always
Skip navigation links
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.