Share via


DistributedCacheExtensions.SetStringAsync 方法

定义

重载

SetStringAsync(IDistributedCache, String, String, CancellationToken)

使用指定的键在指定的缓存中异步设置字符串。

SetStringAsync(IDistributedCache, String, String, DistributedCacheEntryOptions, CancellationToken)

使用指定的键在指定的缓存中异步设置字符串。

SetStringAsync(IDistributedCache, String, String, CancellationToken)

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

使用指定的键在指定的缓存中异步设置字符串。

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

参数

cache
IDistributedCache

用于存储数据的缓存。

key
String

用于存储数据的键。

value
String

要存储在缓存中的数据。

token
CancellationToken

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

返回

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

例外

keyvalue 为 null。

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

注解

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

适用于

SetStringAsync(IDistributedCache, String, String, DistributedCacheEntryOptions, CancellationToken)

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

使用指定的键在指定的缓存中异步设置字符串。

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

参数

cache
IDistributedCache

用于存储数据的缓存。

key
String

用于存储数据的键。

value
String

要存储在缓存中的数据。

options
DistributedCacheEntryOptions

值的缓存选项。

token
CancellationToken

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

返回

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

例外

keyvalue 为 null。

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

注解

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

适用于