Adds a key/value pair to the NamedMapTKey, TValue if the key does not already exist,
or updates a key/value pair in the NamedMapTKey, TValue if the key already exists.
Namespace: Soss.Client.Concurrent
Assembly: soss_namedcache (in soss_namedcache.dll) Version: 6.2.0.0
Syntax
public TValue AddOrUpdate( TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory )
Parameters
- key
- Type: TKey
The key to be added or whose value should be updated. - addValue
- Type: TValue
The function used to generate a value for an absent key. - updateValueFactory
- Type: SystemFuncTKey, TValue, TValue
The function used to generate a new value for an existing key based on the key's existing value
Return Value
Type: TValueA new value for the key. This will be either addValue (if the key was absent) or the result of updateValueFactory (if the key was present).
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown if key is a null reference or updateValueFactory is a null reference. |
TimeoutException | Thrown when the maximum number of internal retries reached. |
See Also