DistributedNotableDateCacheExtensions Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.Caching.Distributed.dll
- Package
- Bodu.Globalization.Calendar.Caching.Distributed 1.0.0
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
servicesIServiceCollectionThe service collection to add the registration to.
configurationIConfigurationAn optional configuration root or section bound into DistributedNotableDateCacheOptions.
sectionNamestringThe configuration section name. Defaults to
Calendar:NotableDateCache:Distributed.configureAction<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
servicesis null.- ArgumentException
Thrown when
sectionNameis 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
servicesIServiceCollectionThe service collection to add the registration to.
configureRedisAction<RedisCacheOptions>The callback configuring the Redis cache connection and options.
configurationIConfigurationAn optional configuration root or section bound into DistributedNotableDateCacheOptions.
sectionNamestringThe configuration section name. Defaults to
Calendar:NotableDateCache:Distributed.configureAction<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
servicesorconfigureRedisis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |