DistributedCacheExtensions Class¶
Extension methods for setting data in an Microsoft.Extensions.Caching.Distributed.IDistributedCache
.
- Namespace
Microsoft.Extensions.Caching.Distributed
- Assemblies
- Microsoft.Extensions.Caching.Abstractions
Syntax¶
public class DistributedCacheExtensions
-
class
Microsoft.Extensions.Caching.Distributed.
DistributedCacheExtensions
Methods¶
-
GetString
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String)¶ Gets a string from the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to get the stored data for.
Return type: System.String
Returns: The string value from the stored cache key.
public static string GetString(this IDistributedCache cache, string key)
-
GetStringAsync
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String)¶ Asynchronously gets a string from the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to get the stored data for.
Return type: System.Threading.Tasks.Task<System.String>
Returns: A task that gets the string value from the stored cache key.
public static Task<string> GetStringAsync(this IDistributedCache cache, string key)
-
Set
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.Byte[])¶ Sets a sequence of bytes in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.Byte<System.Byte>[]) – The data to store in the cache.
public static void Set(this IDistributedCache cache, string key, byte[] value)
-
SetAsync
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.Byte[])¶ Asynchronously sets a sequence of bytes in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.Byte<System.Byte>[]) – The data to store in the cache.
Return type: System.Threading.Tasks.Task
Returns: A task that represents the asynchronous set operation.
public static Task SetAsync(this IDistributedCache cache, string key, byte[] value)
-
SetString
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.String)¶ Sets a string in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.String) – The data to store in the cache.
public static void SetString(this IDistributedCache cache, string key, string value)
-
SetString
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.String, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions) Sets a string in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.String) – The data to store in the cache.
- options (Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions) – The cache options for the entry.
public static void SetString(this IDistributedCache cache, string key, string value, DistributedCacheEntryOptions options)
-
SetStringAsync
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.String)¶ Asynchronously sets a string in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.String) – The data to store in the cache.
Return type: System.Threading.Tasks.Task
Returns: A task that represents the asynchronous set operation.
public static Task SetStringAsync(this IDistributedCache cache, string key, string value)
-
SetStringAsync
(Microsoft.Extensions.Caching.Distributed.IDistributedCache, System.String, System.String, Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions) Asynchronously sets a string in the specified cache with the specified key.
Arguments: - cache (Microsoft.Extensions.Caching.Distributed.IDistributedCache) – The cache in which to store the data.
- key (System.String) – The key to store the data in.
- value (System.String) – The data to store in the cache.
- options (Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions) – The cache options for the entry.
Return type: System.Threading.Tasks.Task
Returns: A task that represents the asynchronous set operation.
public static Task SetStringAsync(this IDistributedCache cache, string key, string value, DistributedCacheEntryOptions options)
-