DistributedCacheExtensions.SetString Method

Definition

Overloads

SetString(IDistributedCache, String, String)

Sets a string in the specified cache with the specified key.

SetString(IDistributedCache, String, String, DistributedCacheEntryOptions)

Sets a string in the specified cache with the specified key.

SetString(IDistributedCache, String, String)

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

Sets a string in the specified cache with the specified key.

C#
public static void SetString(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, string value);

Parameters

cache
IDistributedCache

The cache in which to store the data.

key
String

The key to store the data in.

value
String

The data to store in the cache.

Exceptions

key or value is null.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

SetString(IDistributedCache, String, String, DistributedCacheEntryOptions)

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

Sets a string in the specified cache with the specified key.

C#
public static void SetString(this Microsoft.Extensions.Caching.Distributed.IDistributedCache cache, string key, string value, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions options);

Parameters

cache
IDistributedCache

The cache in which to store the data.

key
String

The key to store the data in.

value
String

The data to store in the cache.

options
DistributedCacheEntryOptions

The cache options for the entry.

Exceptions

key or value is null.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)