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)

來源:
DistributedCacheExtensions.cs
來源:
DistributedCacheExtensions.cs
來源:
DistributedCacheExtensions.cs
來源:
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[])例外狀況。

適用於