If you need to advanced configuration or configure cache service without appsettings.json file. You can use extension method.
AddCaching method initally read values from appsettings.json file afterwards applies configuration from action method.
// Program.cs (.NET5 and above)publicstaticasyncTaskMain(string[] args){var builder =WebApplication.CreateBuilder(args); // Add with configuration instancevar cacheOptions =newRedisCacheOptions();cacheOptions.Hosts=new [] { "localhost:6379" };cacheOptions.UserName="admin";cacheOptions.Password="your+str0ng_Password!";builder.AddCaching(x =>x.Redis(cacheOptions)); // Add with inline action methodbuilder.AddCaching(x =>x.Redis(x =>x.BacklogPolicy=StackExchange.Redis.BacklogPolicy.FailFast));var app =builder.Build();app.Run();}