DistributedCacheExtensions.SetAsync 方法

定义

重载

SetAsync(IDistributedCache, String, Byte[])

使用指定的键异步设置指定缓存中的字节序列。

SetAsync(IDistributedCache, String, Byte[], CancellationToken)

使用指定的键异步设置指定缓存中的字节序列。

SetAsync(IDistributedCache, String, Byte[])

使用指定的键异步设置指定缓存中的字节序列。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task ^ SetAsync(Microsoft::Extensions::Caching::Distributed::IDistributedCache ^ cache, System::String ^ key, cli::array <System::Byte> ^ value);
public static System.Threading.Tasks.Task SetAsync (this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, byte[] value);
static member SetAsync : Microsoft.Extensions.Caching.Distributed.IDistributedCache * string * byte[] -> System.Threading.Tasks.Task
<Extension()>
Public Function SetAsync (cache As IDistributedCache, key As String, value As Byte()) As Task

参数

cache
IDistributedCache

用于存储数据的缓存。

key
String

用于存储数据的键。

value
Byte[]

要存储在缓存中的数据。

返回

表示异步设置操作的任务。

例外

keyvalue 为 null。

注解

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

适用于

SetAsync(IDistributedCache, String, Byte[], CancellationToken)

Source:
DistributedCacheExtensions.cs
Source:
DistributedCacheExtensions.cs
Source:
DistributedCacheExtensions.cs

使用指定的键异步设置指定缓存中的字节序列。

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

参数

cache
IDistributedCache

用于存储数据的缓存。

key
String

用于存储数据的键。

value
Byte[]

要存储在缓存中的数据。

token
CancellationToken

可选。 用于取消此操作的 CancellationToken

返回

表示异步设置操作的任务。

例外

keyvalue 为 null。

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

注解

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

适用于