Table of Contents

DistributedNotableDateCacheExtensions Class

Definition

Namespace
Bodu.Globalization.Calendar
Assembly
Bodu.Globalization.Calendar.Caching.Distributed.dll
Package
Bodu.Globalization.Calendar.Caching.Distributed 1.0.0
Source
DistributedNotableDateCacheExtensions.cs

Provides the fluent registration of a distributed (Redis-capable) notable-date cache onto an IServiceCollection.

public static class DistributedNotableDateCacheExtensions
Inheritance
DistributedNotableDateCacheExtensions
Inherited Members

Methods

AddDistributedNotableDateCache(IServiceCollection, IConfiguration?, string, Action<DistributedNotableDateCacheOptions>?)

Registers a DistributedNotableDateCache over the IDistributedCache already registered in the container, as the INotableDateCache used by the caching notable-date service.

public static IServiceCollection AddDistributedNotableDateCache(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Calendar:NotableDateCache:Distributed", Action<DistributedNotableDateCacheOptions>? configure = null)

Parameters

services IServiceCollection

The service collection to add the registration to.

configuration IConfiguration

An optional configuration root or section bound into DistributedNotableDateCacheOptions.

sectionName string

The configuration section name. Defaults to Calendar:NotableDateCache:Distributed.

configure Action<DistributedNotableDateCacheOptions>

An optional callback applied after configuration binding.

Returns

IServiceCollection

The same service collection, to allow chaining.

Remarks

The caller is responsible for registering an IDistributedCache (for example via AddStackExchangeRedisCache or AddDistributedMemoryCache); use AddRedisNotableDateCache(IServiceCollection, Action<RedisCacheOptions>, IConfiguration?, string, Action<DistributedNotableDateCacheOptions>?) to register a Redis cache and the notable-date cache together. Compose it with the caching service by resolving the registered cache, for example AddCachedNotableDateService(cacheFactory: sp => sp.GetRequiredService<INotableDateCache>()).

Exceptions

ArgumentNullException

Thrown when services is null.

ArgumentException

Thrown when sectionName is empty or white space.

AddRedisNotableDateCache(IServiceCollection, Action<RedisCacheOptions>, IConfiguration?, string, Action<DistributedNotableDateCacheOptions>?)

Registers a Redis-backed IDistributedCache and a DistributedNotableDateCache over it, as the INotableDateCache used by the caching notable-date service.

public static IServiceCollection AddRedisNotableDateCache(this IServiceCollection services, Action<RedisCacheOptions> configureRedis, IConfiguration? configuration = null, string sectionName = "Calendar:NotableDateCache:Distributed", Action<DistributedNotableDateCacheOptions>? configure = null)

Parameters

services IServiceCollection

The service collection to add the registration to.

configureRedis Action<RedisCacheOptions>

The callback configuring the Redis cache connection and options.

configuration IConfiguration

An optional configuration root or section bound into DistributedNotableDateCacheOptions.

sectionName string

The configuration section name. Defaults to Calendar:NotableDateCache:Distributed.

configure Action<DistributedNotableDateCacheOptions>

An optional callback applied after configuration binding.

Returns

IServiceCollection

The same service collection, to allow chaining.

Remarks

A convenience over AddDistributedNotableDateCache(IServiceCollection, IConfiguration?, string, Action<DistributedNotableDateCacheOptions>?) that first registers a Redis IDistributedCache via AddStackExchangeRedisCache, then registers the notable-date cache over it.

Exceptions

ArgumentNullException

Thrown when services or configureRedis is null.

ArgumentException

Thrown when sectionName is empty or white space.

Applies to

ProductVersions
.NET8, 10