Add SQL Server distributed cache configuration

Configured the application to use SQL Server as a distributed
cache provider. Added `AddDistributedSqlServerCache` to
`Program.cs` and set up the connection string, schema name,
and table name from the `Cache:SqlServer` configuration
section. This enables persistent and shared caching across
multiple application instances.
This commit is contained in:
2026-06-09 13:52:30 +02:00
parent f35068e368
commit 308cdd03f2

View File

@@ -269,6 +269,15 @@ try
// Cache options
builder.Services.Configure<CacheOptions>(config.GetSection(CacheOptions.SectionName));
// Distributed Cache - SQL Server
var sqlCacheConfig = config.GetSection("Cache:SqlServer");
builder.Services.AddDistributedSqlServerCache(options =>
{
options.ConnectionString = sqlCacheConfig["ConnectionString"] ?? connStr;
options.SchemaName = sqlCacheConfig["SchemaName"];
options.TableName = sqlCacheConfig["TableName"];
});
// Envelope generator serives
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services