Class RedisSentinelCacheExtension
- Namespace
- Arc4u.Configuration.Redis
- Assembly
- Arc4u.Caching.dll
Extension methods to register the options of a Redis Sentinel cache.
public static class RedisSentinelCacheExtension
- Inheritance
-
RedisSentinelCacheExtension
- Inherited Members
Methods
AddRedisSentinelCache(IServiceCollection, string, IConfiguration, string)
Registers the options of the Redis Sentinel cache with the given name from a configuration section. Nothing is registered when the section does not exist.
public static IServiceCollection AddRedisSentinelCache(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 RedisSentinelCacheOption values.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Exceptions
- ArgumentException
The section exists but the name, the master name or the instance name is null or empty, or its sentinel endpoints are empty.
AddRedisSentinelCache(IServiceCollection, string, Action<RedisSentinelCacheOption>)
Registers the options of the Redis Sentinel cache with the given name.
public static IServiceCollection AddRedisSentinelCache(this IServiceCollection services, string name, Action<RedisSentinelCacheOption> options)
Parameters
servicesIServiceCollectionThe service collection.
namestringThe name of the cache, as used in Name.
optionsAction<RedisSentinelCacheOption>The action that configures the options; the master name, at least one sentinel endpoint and the instance name are required.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Examples
builder.Services.AddRedisSentinelCache("Shared", o =>
{
o.InstanceName = "MyApp";
o.MasterName = "mymaster";
o.SentinelEndpoints = ["sentinel1:26379", "sentinel2:26379"];
});
Exceptions
- ArgumentException
name, the master name or the instance name is null or empty, or the sentinel endpoints are empty.- ArgumentNullException
The sentinel endpoints are null.