Table of Contents

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

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 RedisCacheOption values.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

Exceptions

ArgumentException

name or 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

services IServiceCollection

The service collection.

name string

The name of the cache, as used in Name.

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