TailoredApps.Shared.Mediator.Caching 3.0.0-preview.3

This is a prerelease version of TailoredApps.Shared.Mediator.Caching.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TailoredApps.Shared.Mediator.Caching" Version="3.0.0-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TailoredApps.Shared.Mediator.Caching" Version="3.0.0-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="TailoredApps.Shared.Mediator.Caching" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TailoredApps.Shared.Mediator.Caching --version 3.0.0-preview.3
                    
#r "nuget: TailoredApps.Shared.Mediator.Caching, 3.0.0-preview.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TailoredApps.Shared.Mediator.Caching@3.0.0-preview.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TailoredApps.Shared.Mediator.Caching&version=3.0.0-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=TailoredApps.Shared.Mediator.Caching&version=3.0.0-preview.3&prerelease
                    
Install as a Cake Tool

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.Mediator namespace and the mediator is registered with AddMediator(...). In 2.x this package was named TailoredApps.Shared.MediatR.Caching.

  • The interface is a marker with a key; nothing in this package stores or reads a cache.

  • CachingBehavior in TailoredApps.Shared.Mediator does not look at ICachableRequest<TResponse>. It caches a request only when an ICachePolicy<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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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