Bsft.Caching.Mediator
2.2.0
dotnet add package Bsft.Caching.Mediator --version 2.2.0
NuGet\Install-Package Bsft.Caching.Mediator -Version 2.2.0
<PackageReference Include="Bsft.Caching.Mediator" Version="2.2.0" />
<PackageVersion Include="Bsft.Caching.Mediator" Version="2.2.0" />
<PackageReference Include="Bsft.Caching.Mediator" />
paket add Bsft.Caching.Mediator --version 2.2.0
#r "nuget: Bsft.Caching.Mediator, 2.2.0"
#:package Bsft.Caching.Mediator@2.2.0
#addin nuget:?package=Bsft.Caching.Mediator&version=2.2.0
#tool nuget:?package=Bsft.Caching.Mediator&version=2.2.0
Bsft.Caching.Mediator
The behavior package of the Bsft.Caching family: a mediator pipeline behavior that serves
cacheable queries from the configured cache store and writes the handler's result back on a miss.
Install
dotnet add package Bsft.Caching.Mediator
Requires Bsft.Caching and Bsft.Mediator.Abstractions (both pulled transitively). It exists as
its own package so that a host caching by hand — through ICacheStore and ICacheInvalidator —
takes no mediator dependency at all.
Register
services.AddBsftCaching();
services.AddBsftCachingMediator();
Then mark the queries whose results may be cached:
public sealed record GetProductQuery(Guid Id) : IQuery<Product>, ICacheable
{
public string CacheKey => Id.ToString();
}
Nothing else is required. Call this after AddBsftMediator and after every authorization behavior:
the mediator runs behaviors in registration order, innermost last, so a behavior registered after
this one no longer runs on a cache hit. Calling it twice registers a single behavior.
Configure
| Option | Default | Effect |
|---|---|---|
| — | — | The package has no options type. Lifetime and key prefix come from BsftCachingOptions (section Bsft:Caching) in Bsft.Caching, and per-request lifetime and tags come from ICacheable. |
Validation: none here — Bsft.Caching validates the options both packages read.
Extend
None of its own. What the behavior does is decided by the seams of Bsft.Caching:
ICacheStore (where entries live), ICacheKeyBuilder and ICacheKeyScopeProvider (how a key is
composed and scoped) and ICacheTagIndex (which keys a tag reaches). Replace them there.
A command carrying ICacheable is never served from the cache, a null result and a non-positive
lifetime are not written, and a store or tag index that cannot be reached degrades the request to an
uncached one rather than failing it.
Documentation
Topic page: docs/caching.md. Conventions: docs/package-conventions.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bsft.Caching (>= 2.2.0)
- Bsft.Mediator.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
-
net8.0
- Bsft.Caching (>= 2.2.0)
- Bsft.Mediator.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging (>= 9.0.19)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.