Class SqlCacheExtension
- Namespace
- Arc4u.Configuration.Sql
- Assembly
- Arc4u.Caching.dll
Extension methods to register the options of a SQL Server cache.
public static class SqlCacheExtension
- Inheritance
-
SqlCacheExtension
- Inherited Members
Methods
AddSqlCache(IServiceCollection, string, IConfiguration, string)
Registers the options of the SQL Server cache with the given name from a configuration section. Nothing is registered when the section does not exist.
public static IServiceCollection AddSqlCache(this IServiceCollection services, string name, IConfiguration configuration, string sectionName)
Parameters
servicesIServiceCollectionThe service collection.
namestringThe name of the cache, as used in Name.
configurationIConfigurationThe application configuration.
sectionNamestringThe path of the section that holds the SqlCacheOption values.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Exceptions
- ArgumentException
nameis null or empty and the section exists.
AddSqlCache(IServiceCollection, string, Action<SqlCacheOption>)
Registers the options of the SQL Server cache with the given name.
public static IServiceCollection AddSqlCache(this IServiceCollection services, string name, Action<SqlCacheOption> options)
Parameters
servicesIServiceCollectionThe service collection.
namestringThe name of the cache, as used in Name.
optionsAction<SqlCacheOption>The action that configures the options.
Returns
- IServiceCollection
The same IServiceCollection, for chaining.
Examples
builder.Services.AddSqlCache("Shared", o => o.ConnectionString = "Server=.;Database=Cache;Integrated Security=true");
Exceptions
- ArgumentException
nameis null or empty.