liveBook · Manning

AddDistributedSqlServerCache

As explained in Pro ASP.NET Core 7, Tenth Edition

An ASP.NET Core service-registration method that configures an IDistributedCache implementation backed by a SQL Server database.

AddDistributedSqlServerCache registers an IDistributedCache implementation backed by SQL Server. Unlike in-process distributed memory caching, it lets multiple ASP.NET Core servers share entries and preserves them when the application stops. section 17.2.2

Register the persistent cache

builder.Services.AddDistributedSqlServerCache(opts => { opts.ConnectionString = builder.Configuration["ConnectionStrings:CacheConnection"]; opts.SchemaName = "dbo"; opts.TableName = "DataCache"; });

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Descends through database creation, table provisioning, package installation, configuration, and service registration, but not cache internals.
Examples
Uses LocalDB, CacheDb, the dbo.DataCache table, appsettings.json, and a Program.cs registration.
What it assumes
Assumes ASP.NET Core configuration and dependency injection, while demonstrating database and cache-table setup from zero.
What you can do after
Operate/configure it with a SQL Server connection string and explicit cache schema and table names.
How it connects
Connects distributed caching with SQL Server, connection strings, ASP.NET Core dependency injection, and configuration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.