Bsft.Caching.Data
2.2.0
dotnet add package Bsft.Caching.Data --version 2.2.0
NuGet\Install-Package Bsft.Caching.Data -Version 2.2.0
<PackageReference Include="Bsft.Caching.Data" Version="2.2.0" />
<PackageVersion Include="Bsft.Caching.Data" Version="2.2.0" />
<PackageReference Include="Bsft.Caching.Data" />
paket add Bsft.Caching.Data --version 2.2.0
#r "nuget: Bsft.Caching.Data, 2.2.0"
#:package Bsft.Caching.Data@2.2.0
#addin nuget:?package=Bsft.Caching.Data&version=2.2.0
#tool nuget:?package=Bsft.Caching.Data&version=2.2.0
Bsft.Caching.Data
Folds the current tenant into every cache key, so a cacheable query answered for one tenant is never
served to another, and bypasses the cache entirely while no tenant is resolved. It is the caching
family's bridge to Bsft.Data's multi-tenancy.
Install
dotnet add package Bsft.Caching.Data
Requires Bsft.Caching for the key builder that reads the scope and Bsft.Data for the tenant
context (both pulled transitively). It is a separate package so that neither family depends on the
other: a single-tenant host caches without the data layer, and a multi-tenant host that caches
nothing takes no cache.
Register
services.AddBsftDataMultiTenancy(configuration, tenancy => tenancy.ResolveFromClaim());
services.AddBsftCaching(configuration);
services.AddBsftCachingMediator();
services.AddBsftCachingData(); // tenant-scoped cache keys
Nothing else is required, and the order of the calls does not matter: the tenant-blind default
GlobalCacheKeyScopeProvider is removed rather than merely tried past. Leaving the call out of a
multi-tenant host is reported as a startup warning by Bsft.Data.
Configure
| Option | Default | Effect |
|---|---|---|
CachingDataDefaults.TenantScopePrefix |
tenant: |
The prefix a resolved tenant's scope carries, followed by the tenant identifier. |
Validation: none — the package has nothing a deployment states.
While no tenant is resolved
The provider then reports CacheKeyScope.NotCacheable, and CachingBehavior runs the request
through its handler without reading or writing the cache. It does not fall back to a substitute
scope: every request that failed to resolve would share it, and one of them may still produce a
tenant-specific result — a host authenticating through another mechanism, a header dropped in front
of the app, a caller omitting it on purpose — which the next unresolved request would then be served.
The cost is the missed hit for such requests; nothing is written, so there is no shared bucket and no
garbage in the store. Within one request the tenant may still arrive late: caching starts from the
call that sees it.
Extend
ICacheKeyScopeProvider (what every cache key is qualified with; this package supplies the tenant).
A host that also caches per user registers its own provider folding both in: this package adds with
TryAdd, so a provider registered before it wins. A provider of your own returns
CacheKeyScope.NotCacheable for the same reason whenever its context did not resolve.
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.Data (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
-
net8.0
- Bsft.Caching (>= 2.2.0)
- Bsft.Data (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 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.