MemoryDistributedCache.GetAsync(String, CancellationToken) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Asynchronously gets the specified item associated with a key from the IMemoryCache as a byte array.
public System.Threading.Tasks.Task<byte[]?> GetAsync (string key, System.Threading.CancellationToken token = default);
abstract member GetAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<byte[]>
override this.GetAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<byte[]>
Public Function GetAsync (key As String, Optional token As CancellationToken = Nothing) As Task(Of Byte())
Parameters
- key
- String
The key of the item to get.
- token
- CancellationToken
The CancellationToken to use to cancel operation.
Returns
The task for getting the byte array value associated with the specified key from the cache.
Implements
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Get(String).