Table of Contents

RateCacheWarmupExtensions Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Caching.dll
Package
Bodu.Financial.ExchangeRates.Caching 1.0.0
Source
RateCacheWarmupExtensions.cs

Provides registration of the startup cache warm-up onto an IFinancialServiceBuilder.

public static class RateCacheWarmupExtensions
Inheritance
RateCacheWarmupExtensions
Inherited Members

Methods

AddRateCacheWarmup(IFinancialServiceBuilder, IConfiguration?, string, Action<RateCacheWarmupOptions>?)

Registers a hosted service that warms every registered caching rate provider at application start, fetching the configured pairs over the configured window through the normal read-through path so the first user request never pays the origin fetch.

public static IFinancialServiceBuilder AddRateCacheWarmup(this IFinancialServiceBuilder builder, IConfiguration? configuration = null, string sectionName = "Financial:RateCacheWarmup", Action<RateCacheWarmupOptions>? configure = null)

Parameters

builder IFinancialServiceBuilder

The financial service builder.

configuration IConfiguration

An optional configuration root or section bound into RateCacheWarmupOptions.

sectionName string

The configuration section name. Defaults to Financial:RateCacheWarmup.

configure Action<RateCacheWarmupOptions>

An optional callback applied after configuration binding.

Returns

IFinancialServiceBuilder

The builder, for chaining.

Examples

services.AddFinancialService()
        .AddRbaExchangeRates(configuration)
        .AddCachedRateProvider<RbaRateProvider>("RBA", configuration)
        .AddRateCacheWarmup(configure: warmup =>
        {
            warmup.Pairs.Add("AUD/USD");
            warmup.Pairs.Add("AUD/EUR");
            warmup.LookbackDays = 90;
        });

Remarks

The warm-up runs in the background after the host starts and never blocks or crashes it: a failing pair is logged and skipped, and host shutdown cancels the run. It warms every provider registered through AddCachedRateProvider automatically; aggregation children registered through AddAggregatedRateProvider are keyed services and are warmed only when named in Providers. Options are validated at application start.

Exceptions

ArgumentNullException

Thrown when builder is null.

ArgumentException

Thrown when sectionName is empty or white space.

Applies to

ProductVersions
.NET8, 10