MemoryDistributedCache.SetAsync 方法

定义

异步设置与字节数组中的 IMemoryCache 键关联的指定项。

public System.Threading.Tasks.Task SetAsync(string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options, System.Threading.CancellationToken token = default);
abstract member SetAsync : string * byte[] * Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.SetAsync : string * byte[] * Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function SetAsync (key As String, value As Byte(), options As DistributedCacheEntryOptions, Optional token As CancellationToken = Nothing) As Task

参数

key
String

要设置的项的键。

value
Byte[]

要设置的项的字节数组值。

options
DistributedCacheEntryOptions

要设置的项的缓存选项。

token
CancellationToken

CancellationToken用于取消操作。

返回

用于设置与缓存中指定键关联的字节数组值的任务。

实现

例外

取消令牌已取消。 此异常存储在返回的任务中。

注解

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Set(String, Byte[], DistributedCacheEntryOptions)..

适用于