Table of Contents

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

services IServiceCollection

The service collection.

name string

The name of the cache, as used in Name.

configuration IConfiguration

The application configuration.

sectionName string

The 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

services IServiceCollection

The service collection.

name string

The name of the cache, as used in Name.

options Action<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.