RedisCache.SetAsync 方法

定义

重载

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

设置具有给定键的值。

SetAsync(String, Byte[], DistributedCacheEntryOptions)

public:
 virtual System::Threading::Tasks::Task ^ SetAsync(System::String ^ key, cli::array <System::Byte> ^ value, Microsoft::Extensions::Caching::Distributed::DistributedCacheEntryOptions ^ options);
public System.Threading.Tasks.Task SetAsync (string key, byte[] value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options);
abstract member SetAsync : string * byte[] * Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions -> System.Threading.Tasks.Task
override this.SetAsync : string * byte[] * Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions -> System.Threading.Tasks.Task
Public Function SetAsync (key As String, value As Byte(), options As DistributedCacheEntryOptions) As Task

参数

key
String
value
Byte[]

返回

实现

注解

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

适用于

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

设置具有给定键的值。

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,用于传播应取消操作的通知。

返回

表示异步操作的 Task

实现

例外

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

注解

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

适用于