IMapTKey, TValuePutIfAbsent Method (TKey, TValue)Hazelcast .Net Client Class Library
If the specified key is not already associated with a value, associate it with the given value.

Namespace: Hazelcast.Core
Assembly: Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.8.2
Syntax

TValue PutIfAbsent(
	TKey key,
	TValue value
)

Parameters

key
Type: TKey
key
value
Type: TValue
value

Return Value

Type: TValue
previous value associated with key or null if there was no mapping for key .
Remarks

If the specified key is not already associated with a value, associate it with the given value. This is equivalent to
if (!map.ContainsKey(key))
    return map.Put(key, value);
else
    return map.Get(key);
except that the action is performed atomically.

Warning:

This method uses GetHashCode and Equals of binary form of the key, not the actual implementations of GetHashCode and Equals defined in key's class.

Warning-2:

This method returns a clone of previous value, not the original (identically equal) value previously put into map.

See Also

Reference