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)引发的异常。

适用于