TailoredApps.Shared.Mediator.Caching
3.0.0-preview.3
dotnet add package TailoredApps.Shared.Mediator.Caching --version 3.0.0-preview.3
NuGet\Install-Package TailoredApps.Shared.Mediator.Caching -Version 3.0.0-preview.3
<PackageReference Include="TailoredApps.Shared.Mediator.Caching" Version="3.0.0-preview.3" />
<PackageVersion Include="TailoredApps.Shared.Mediator.Caching" Version="3.0.0-preview.3" />
<PackageReference Include="TailoredApps.Shared.Mediator.Caching" />
paket add TailoredApps.Shared.Mediator.Caching --version 3.0.0-preview.3
#r "nuget: TailoredApps.Shared.Mediator.Caching, 3.0.0-preview.3"
#:package TailoredApps.Shared.Mediator.Caching@3.0.0-preview.3
#addin nuget:?package=TailoredApps.Shared.Mediator.Caching&version=3.0.0-preview.3&prerelease
#tool nuget:?package=TailoredApps.Shared.Mediator.Caching&version=3.0.0-preview.3&prerelease
TailoredApps.Shared.Mediator.Caching
A contracts-only package with one interface, ICachableRequest<TResponse>: a mediator request that names its
own cache key. It lets a request type say how its response is identified in a cache without referencing any
caching implementation.
Installation
dotnet add package TailoredApps.Shared.Mediator.Caching
Registration
Nothing to register: the package has no dependency-injection extension and no services.
Usage
using TailoredApps.Shared.Mediator.Caching;
public class GetUserProfile : ICachableRequest<UserProfileDto>
{
public int UserId { get; init; }
public string Language { get; init; } = "en";
public string GetCacheKey() => $"user-profile:{UserId}:{Language}";
}
ICachableRequest<TResponse> extends IRequest<TResponse>, so the request is sent and handled like any other
mediator request.
Good to know
Built on ForkForward.Mediator, a fork of MediatR 12.5.0 under the Apache-2.0 licence, not on the MediatR package: requests and handlers use the
ForkForward.Mediatornamespace and the mediator is registered withAddMediator(...). In 2.x this package was namedTailoredApps.Shared.MediatR.Caching.The interface is a marker with a key; nothing in this package stores or reads a cache.
CachingBehaviorinTailoredApps.Shared.Mediatordoes not look atICachableRequest<TResponse>. It caches a request only when anICachePolicy<TRequest, TResponse>is registered for it. To cache the request above with that behaviour, add a policy that returns the request's own key:using TailoredApps.Shared.Mediator.Interfaces.Caching; public class GetUserProfileCachePolicy : ICachePolicy<GetUserProfile, UserProfileDto> { public string GetCacheKey(GetUserProfile request) => request.GetCacheKey(); }The key is all that identifies a cached response. Put every value that changes the response into it, including the user or tenant when the data is per user.
Safe for trimming and NativeAOT. A policy that returns
request.GetCacheKey()needs no reflection, unlike the default cache key.
Documentation
https://shared.tailoredapps.pl/en/Libraries/Mediator/Caching/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net11.0 is compatible. |
-
net10.0
- ForkForward.Mediator (>= 13.0.0)
-
net11.0
- ForkForward.Mediator (>= 13.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TailoredApps.Shared.Mediator.Caching:
| Package | Downloads |
|---|---|
|
TailoredApps.Shared.Mediator
Pipeline behaviours for ForkForward.Mediator registered in one place: logging, FluentValidation, response caching (HybridCache), fallback and retry with a circuit breaker. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-preview.3 | 50 | 12/2/2026 |