Package com.hazelcast.cp
Interface CPMap<K,V>
- Type Parameters:
K- KeyV- Value
- All Superinterfaces:
DistributedObject
CPMap is a key-value store within CP. It can be accessed via
CPSubsystem.getMap(String).
A CPMap must be able to fit within the member's host RAM. A CPMap is not partitioned like an
IMap.
- Since:
- 5.4
-
Method Summary
Modifier and TypeMethodDescriptionbooleancompareAndSet(K key, V expectedValue, V newValue) Atomically setskeytonewValueif the current value forkeyis equal-toexpectedValue.voidRemoveskeyif present.Gets the value associated withkeyAssociateskeywithvalue.putIfAbsent(K key, V value) Associateskeywithvalueonly ifkeyis not present.Removeskeyif present.voidAssociateskeywithvalue.Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
Method Details
-
put
Associateskeywithvalue.See
set(K, V)for a more optimal solution when the previous value of @{code key} is not relevant.- Parameters:
key- non-null key of the entryvalue- non-null value of the entry- Returns:
- null if
keyhad no previous mapping, otherwise the previous value associated withkey - Throws:
NullPointerException- whenkeyorvalueis null
-
putIfAbsent
Associateskeywithvalueonly ifkeyis not present.- Parameters:
key- non-null key of the entryvalue- non-null value of the entry- Returns:
- null if
keyhad no previous mapping, otherwise the value associated withkey - Throws:
NullPointerException- whenkeyorvalueis null
-
set
Associateskeywithvalue.This method should be preferred over
put(K, V)as it has a smaller network footprint due to the previous value associated withkeynot being transmitted. Useput(K, V)only when the previous value ofkeyis required.- Parameters:
key- non-null key of the entryvalue- non-null value of the entry- Throws:
NullPointerException- whenkeyorvalueis null
-
remove
Removeskeyif present.- Parameters:
key- non-null key of the key-value entry to remove- Returns:
- null if
keywas not present, otherwise the value associated withkey - Throws:
NullPointerException- whenkeyis null
-
delete
Removeskeyif present.- Parameters:
key- non-null key of the key-value entry to remove- Throws:
NullPointerException- whenkeyis null
-
compareAndSet
Atomically setskeytonewValueif the current value forkeyis equal-toexpectedValue.- Parameters:
key- non-null key of the entryexpectedValue- non-null expected value associated withkeynewValue- non-null new value to associate withkey- Returns:
- true if
keywas associated withnewValue, otherwise false - Throws:
NullPointerException- whenkey,expectedValueornewValueis null
-
get
Gets the value associated withkey- Parameters:
key- non-null key of the entry- Returns:
- null if
keyhad no association, otherwise the value associated withkey - Throws:
NullPointerException- whenkeyis null
-