Class RedisCacheExtension
- Namespace
- Arc4u.Configuration.Redis
- Assembly
- Arc4u.Caching.dll
Extension methods to register the options of a Redis cache.
public static class RedisCacheExtension
- Inheritance
-
RedisCacheExtension
- Inherited Members
Methods
AddRedisCache(IServiceCollection, string, IConfiguration, string)
Registers the options of the Redis cache with the given name from a configuration section. Nothing is registered when the section does not exist.
public static IServiceCollection AddRedisCache(this IServiceCollection services, string name, IConfiguration configuration, string sectionName)
Parameters
servicesIServiceCollectionThe service collection.
namestringThe name of the cache, as used in Name.
configurationIConfigurationThe application configuration.
sectionNamestringThe path of the section that holds the RedisCacheOption values.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Exceptions
- ArgumentException
nameor the connection string is null or empty and the section exists.
AddRedisCache(IServiceCollection, string, Action<RedisCacheOption>)
Registers the options of the Redis cache with the given name.
public static IServiceCollection AddRedisCache(this IServiceCollection services, string name, Action<RedisCacheOption> options)
Parameters
servicesIServiceCollectionThe service collection.
namestringThe name of the cache, as used in Name.
optionsAction<RedisCacheOption>The action that configures the options; ConnectionString and InstanceName are required.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Examples
builder.Services.AddRedisCache("Shared", o => o.ConnectionString = "localhost:6379");
Exceptions
- ArgumentException
name, the connection string or the instance name is null or empty.