| IMapTKey, TValuePutAsync Method (TKey, TValue, Int64, TimeUnit) |
Asynchronously puts the given key and value into this map with a given ttl (time to live) value.
Namespace:
Hazelcast.Core
Assembly:
Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.12.3
Syntax Task<TValue> PutAsync(
TKey key,
TValue value,
long ttl,
TimeUnit timeunit
)
Function PutAsync (
key As TKey,
value As TValue,
ttl As Long,
timeunit As TimeUnit
) As Task(Of TValue)
Task<TValue>^ PutAsync(
TKey key,
TValue value,
long long ttl,
TimeUnit timeunit
)
abstract PutAsync :
key : 'TKey *
value : 'TValue *
ttl : int64 *
timeunit : TimeUnit -> Task<'TValue>
Parameters
- key
- Type: TKey
the key of the map entry - value
- Type: TValue
the new value of the map entry - ttl
- Type: SystemInt64
maximum time for this entry to stay in the map
0 means infinite.
- timeunit
- Type: Hazelcast.CoreTimeUnit
time unit for the ttl
Return Value
Type:
TaskTValueTask<V> from which the old value of the key can be retrieved.
Remarks
Asynchronously puts the given key and value into this map with a given ttl (time to live) value.
Entry will expire and get evicted after the ttl. If ttl is 0, then
the entry lives forever.
Task<V> task = map.PutAsync(key, value, ttl, timeunit);
V oldValue = task.Result;
Task.Result will block until the actual map.Put() completes.
If the application requires timely response,
then task.Wait(timeout) can be used.
try
{
Task<V> task = map.PutAsync(key, value, ttl, timeunit);
if(task.Wait(TimeSpan.FromMilliseconds(40)))
{
V value = task.Result;
}
else
{
}
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.
See Also Reference
System.Threading.TasksTaskTResult