SqliteNotableDateCacheExtensions Class
Definition
- Namespace
- Bodu.Globalization.Calendar
- Assembly
- Bodu.Globalization.Calendar.Caching.Sqlite.dll
- Package
- Bodu.Globalization.Calendar.Caching.Sqlite 1.0.0
Provides the fluent registration of a SQLite-backed notable-date cache onto an IServiceCollection.
public static class SqliteNotableDateCacheExtensions
- Inheritance
-
SqliteNotableDateCacheExtensions
- Inherited Members
Methods
AddSqliteNotableDateCache(IServiceCollection, IConfiguration?, string, Action<SqliteNotableDateCacheOptions>?)
Registers a SqliteNotableDateCache as the INotableDateCache used by the caching notable-date service.
public static IServiceCollection AddSqliteNotableDateCache(this IServiceCollection services, IConfiguration? configuration = null, string sectionName = "Calendar:NotableDateCache:Sqlite", Action<SqliteNotableDateCacheOptions>? configure = null)
Parameters
servicesIServiceCollectionThe service collection to add the registration to.
configurationIConfigurationAn optional configuration root or section bound into SqliteNotableDateCacheOptions.
sectionNamestringThe configuration section name. Defaults to
Calendar:NotableDateCache:Sqlite.configureAction<SqliteNotableDateCacheOptions>An optional callback applied after configuration binding.
Returns
- IServiceCollection
The same service collection, to allow chaining.
Examples
services.AddNotableDateService(AmericasCalendarData.LoadResource("US"));
services.AddSqliteNotableDateCache(configure: o => o.DatabaseFilePath = "/var/cache/holidays.db");
services.AddCachedNotableDateService(cacheFactory: sp => sp.GetRequiredService<INotableDateCache>());
Remarks
The cache is registered as a singleton so its keep-alive connection is shared and the container disposes it on
shutdown. Compose it with the caching service by resolving the registered cache - for example
AddCachedNotableDateService(cacheFactory: sp => sp.GetRequiredService<INotableDateCache>()).
Exceptions
- ArgumentNullException
Thrown when
servicesis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |