CodeCargo.Nats.DistributedCache 0.1.0

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

CodeCargo.Nats.DistributedCache

Overview

A .NET 8+ library for integrating NATS as a distributed cache in ASP.NET Core applications. Supports the new HybridCache system for fast, scalable caching.

Installation

dotnet add package CodeCargo.Nats.DistributedCache

Usage

using Microsoft.Extensions.DependencyInjection;
using NATS.Client.Core;
using CodeCargo.NatsDistributedCache;

var builder = WebApplication.CreateBuilder(args);

// Add a NATS connection
var natsOpts = NatsOpts.Default with { Url = "nats://localhost:4222" }
builder.Services.AddNats(opts => natsOpts);

// Add a NATS distributed cache
builder.Services.AddNatsDistributedCache(options =>
{
    options.BucketName = "cache";
});

// (Optional) Add HybridCache
var hybridCacheServices = builder.Services.AddHybridCache();

// (Optional) Use NATS Serializer for HybridCache
hybridCacheServices.AddSerializerFactory(
  natsOpts.SerializerRegistry.ToHybridCacheSerializerFactory());

var app = builder.Build();
app.Run();

Additional Resources

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 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 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on CodeCargo.Nats.DistributedCache:

Package Downloads
CodeCargo.Nats.HybridCacheExtensions

Extensions for using HybridCache with NATS.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0-preview.2 199 5/26/2025
0.3.0-preview.1 111 5/25/2025
0.2.0 157 5/19/2025
0.2.0-preview.1 122 5/19/2025
0.1.2 148 5/16/2025
0.1.1 171 5/16/2025
0.1.0 187 5/12/2025