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 TypeMethodDescriptionboolean
compareAndSet
(K key, V expectedValue, V newValue) Atomically setskey
tonewValue
if the current value forkey
is equal-toexpectedValue
.void
Removeskey
if present.Gets the value associated withkey
Associateskey
withvalue
.putIfAbsent
(K key, V value) Associateskey
withvalue
only ifkey
is not present.Removeskey
if present.void
Associateskey
withvalue
.Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getDestroyContextForTenant, getName, getPartitionKey, getServiceName
-
Method Details
-
put
Associateskey
withvalue
.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
key
had no previous mapping, otherwise the previous value associated withkey
- Throws:
NullPointerException
- whenkey
orvalue
is null
-
putIfAbsent
Associateskey
withvalue
only ifkey
is not present.- Parameters:
key
- non-null key of the entryvalue
- non-null value of the entry- Returns:
- null if
key
had no previous mapping, otherwise the value associated withkey
- Throws:
NullPointerException
- whenkey
orvalue
is null
-
set
Associateskey
withvalue
.This method should be preferred over
put(K, V)
as it has a smaller network footprint due to the previous value associated withkey
not being transmitted. Useput(K, V)
only when the previous value ofkey
is required.- Parameters:
key
- non-null key of the entryvalue
- non-null value of the entry- Throws:
NullPointerException
- whenkey
orvalue
is null
-
remove
Removeskey
if present.- Parameters:
key
- non-null key of the key-value entry to remove- Returns:
- null if
key
was not present, otherwise the value associated withkey
- Throws:
NullPointerException
- whenkey
is null
-
delete
Removeskey
if present.- Parameters:
key
- non-null key of the key-value entry to remove- Throws:
NullPointerException
- whenkey
is null
-
compareAndSet
Atomically setskey
tonewValue
if the current value forkey
is equal-toexpectedValue
.- Parameters:
key
- non-null key of the entryexpectedValue
- non-null expected value associated withkey
newValue
- non-null new value to associate withkey
- Returns:
- true if
key
was associated withnewValue
, otherwise false - Throws:
NullPointerException
- whenkey
,expectedValue
ornewValue
is null
-
get
Gets the value associated withkey
- Parameters:
key
- non-null key of the entry- Returns:
- null if
key
had no association, otherwise the value associated withkey
- Throws:
NullPointerException
- whenkey
is null
-