Default implementation of the ICachingService interface, providing the run-time caching infrastructure.
Namespace: Metalama.Patterns.Caching
Assembly: Metalama.Patterns.Caching.dll
Syntax
public sealed class CachingService : ICachingService, IAsyncDisposable, IDisposableRemarks
The CachingService class is the main run-time component of Metalama Caching. It manages caching profiles, backends, key builders, and value adapters.
When using dependency injection, instances are created via AddMetalamaCaching(IServiceCollection, Action<ICachingServiceBuilder>?). When not using dependency injection, use the Default static property, initialized via the Create(Action<ICachingServiceBuilder>?, IServiceProvider?) method.
Properties
| Name | Description |
|---|---|
| AllBackends | Gets the set of distinct backends used in the service. |
| Default | Gets or sets the default CachingService instance used when dependency injection is disabled. |
| DefaultBackend | Gets default CachingBackend, i.e. the physical storage of cache items. |
| KeyBuilder | Gets the CacheKeyBuilder used to generate caching keys, i.e. to serialize objects into a string. |
| Logger | Gets the FlashtraceSource used for logging caching operations. |
| Profiles | Gets the repository of caching profiles (CachingProfile). |
Methods
| Name | Description |
|---|---|
| Create(Action<ICachingServiceBuilder>?, IServiceProvider?) | Creates a new instance of the CachingService class with the specified configuration. |
| Dispose() | |
| Dispose(CancellationToken) | |
| DisposeAsync() | |
| DisposeAsync(CancellationToken) | |
| InitializeAsync(CancellationToken) | Initializes the caching service. It is recommended to call this method from the start-up program sequence when the back-end involves a network or out-of-process service (e.g. Redis, Azure). If this method is not called, initialization will occur automatically upon the first call any cached method. |