SetAsync Method
SetAsync(TKey, TValue)
Sets (adds or updates) an entry.
Declaration
Task SetAsync(TKey key, TValue value)
Parameters
TKey | key | A key. |
TValue | value | A value. |
Returns
Task | A task that will complete when the entry has been added or updated. |
Remarks
The value has an infinite time-to-live.
The value becomes idle after the server-configured idle time.
SetAsync(TKey, TValue, TimeSpan)
Sets (adds or updates) an entry.
Declaration
Task SetAsync(TKey key, TValue value, TimeSpan timeToLive)
Parameters
TKey | key | A key. |
TValue | value | A value. |
TimeSpan | timeToLive | A time to live (0ms to live forever; -1ms to use the server-configured value). |
Returns
Task | A task that will complete when the entry has been added or updated. |
Remarks
The value is automatically expired, evicted and removed after the
timeToLive
has elapsed. If timeToLive
is0ms, the value is retained
indefinitely. If it is -1ms, it lives for the duration of the server-configured time-to-live.
The value becomes idle after the server-configured idle time.
SetAsync(TKey, TValue, TimeSpan, TimeSpan)
Sets (adds or updates) an entry.
Declaration
Task SetAsync(TKey key, TValue value, TimeSpan timeToLive, TimeSpan maxIdle)
Parameters
TKey | key | A key. |
TValue | value | A value. |
TimeSpan | timeToLive | A time to live (0ms to live forever; -1ms to use the server-configured value). |
TimeSpan | maxIdle | A max-idle time (0ms to never become idle). |
Returns
Task | A task that will complete when the entry has been added or updated. |
Remarks
The value is automatically expired, evicted and removed after the
timeToLive
has elapsed. If timeToLive
is 0ms, the value
is retained indefinitely. If it is -1ms, it lives for the duration of the server-configured time-to-live.
The value is considered idle after the maxIdle
has elapsed. If it is
0ms, the value never becomes idle.