LinKit.Caching 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LinKit.Caching --version 1.0.0
                    
NuGet\Install-Package LinKit.Caching -Version 1.0.0
                    
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="LinKit.Caching" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinKit.Caching" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LinKit.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 LinKit.Caching --version 1.0.0
                    
#r "nuget: LinKit.Caching, 1.0.0"
                    
#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 LinKit.Caching@1.0.0
                    
#: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=LinKit.Caching&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LinKit.Caching&version=1.0.0
                    
Install as a Cake Tool

LinKit.Caching

NuGet Version NuGet Downloads

LinKit.Caching provides high-performance, Zero-Reflection, and Native AOT compatible caching abstractions and providers for LinKit.


🚀 Key Features

  • Zero Reflection & Native AOT Ready: No runtime reflection or dynamic type emit. 100% Native AOT & Trimming safe.
  • Pluggable Architecture: Includes high-throughput InMemoryCacheProvider out-of-the-box, with easy extension points for Distributed Caches (Redis, Garnet, Memcached).
  • Compile-Time Key Resolution: Leverages ICacheKeyResolver<TRequest> for type-safe, compile-time cache key generation.
  • Time-to-Live (TTL) & Sliding Expiration: Full support for absolute expiration and sliding expiration windows.

📦 Installation

dotnet add package LinKit.Caching

🛠️ Usage Guide

1. Register Caching Services in Program.cs

using LinKit.Caching;

var builder = WebApplication.CreateBuilder(args);

// Register default high-throughput In-Memory cache
builder.Services.AddLinKitCaching();

// Or supply a custom distributed cache provider (e.g., Redis):
// builder.Services.AddLinKitCaching<RedisCacheProvider>();

2. Inject and Use ICacheProvider

using LinKit.Caching;

public class GetProductByIdHandler : IQueryHandler<GetProductByIdQuery, ProductDto?>
{
    private readonly ICacheProvider _cache;
    private readonly IProductRepository _repository;

    public GetProductByIdHandler(ICacheProvider cache, IProductRepository repository)
    {
        _cache = cache;
        _repository = repository;
    }

    public async Task<ProductDto?> HandleAsync(GetProductByIdQuery query, CancellationToken ct)
    {
        string cacheKey = $"product:{query.ProductId}";

        // 1. Try get from cache
        var cached = await _cache.GetAsync<ProductDto>(cacheKey, ct);
        if (cached is not null)
        {
            return cached;
        }

        // 2. Fetch from database
        var product = await _repository.FindByIdAsync(query.ProductId, ct);
        if (product is not null)
        {
            // 3. Set cache with TTL
            await _cache.SetAsync(cacheKey, product, ttl: TimeSpan.FromMinutes(10), cancellationToken: ct);
        }

        return product;
    }
}

📄 License

Licensed under the MIT License.

Product 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1 49 10/31/2026
1.3.0 42 10/30/2026
1.2.0 73 10/29/2026
1.1.0 79 10/22/2026
1.0.0 82 10/20/2026