BigInt.AzureRedisCache.MiddleWare 2.0.2

dotnet add package BigInt.AzureRedisCache.MiddleWare --version 2.0.2
                    
NuGet\Install-Package BigInt.AzureRedisCache.MiddleWare -Version 2.0.2
                    
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="BigInt.AzureRedisCache.MiddleWare" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BigInt.AzureRedisCache.MiddleWare" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="BigInt.AzureRedisCache.MiddleWare" />
                    
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 BigInt.AzureRedisCache.MiddleWare --version 2.0.2
                    
#r "nuget: BigInt.AzureRedisCache.MiddleWare, 2.0.2"
                    
#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 BigInt.AzureRedisCache.MiddleWare@2.0.2
                    
#: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=BigInt.AzureRedisCache.MiddleWare&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=BigInt.AzureRedisCache.MiddleWare&version=2.0.2
                    
Install as a Cake Tool

BigInt.AzureRedisCache.MiddleWare

NuGet

A modern, high-performance, and resilient Azure Redis Cache library for .NET applications. This package simplifies Redis integration by providing a robust service-based API with full Dependency Injection support and automatic self-healing.

Key Features

  • Production-Ready: Implements Microsoft's best practices for ConnectionMultiplexer management.
  • Resilient: Automatic "Force Reconnect" logic for handling transient Azure Redis connection issues.
  • Async-First: All operations are asynchronous to prevent thread-blocking.
  • Clean API: Simple IRedisCacheService with GetAsync<T>, SetAsync<T>, and RemoveAsync.
  • Modern Serialization: Uses System.Text.Json (v8+) for high-performance object serialization.
  • DI Friendly: Easy registration via AddAzureRedisCache extension method.
  • Observable: Full integration with ILogger for better diagnostic support.

Installation

dotnet add package BigInt.AzureRedisCache.MiddleWare

Usage by .NET Version

This package is optimized for all modern .NET versions, including .NET 6 (LTS), .NET 8 (LTS), and .NET 10 (Preview).

1. Registration (Program.cs / Minimal API)

All versions starting from .NET 6 use the same clean registration syntax in Program.cs.

using BigInt.AzureRedisCache.MiddleWare;

var builder = <Application>.CreateBuilder(args);

// Register the Azure Redis Cache Service
builder.Services.AddAzureRedisCache(options =>
{
    options.ConnectionString = builder.Configuration.GetConnectionString("Redis");
    options.InstanceName = "MyApp"; // Optional prefix for all keys
    options.DefaultExpiry = TimeSpan.FromHours(24);
    options.ThrowOnError = false; // Prevents app crashes if Redis is down
});

2. Inject and Use

.NET 8 & .NET 10 Style (Primary Constructors)

If you are using .NET 8 or 10, simplify your code using Primary Constructors.

public class MyService(IRedisCacheService cache)
{
    public async Task ProcessDataAsync(string key)
    {
        // Simple Set
        await cache.SetAsync(key, new { Id = 1, Status = "Active" });

        // Simple Get
        var data = await cache.GetAsync<dynamic>(key);
    }
}
.NET 6 Style (Standard DI)

For .NET 6 or older C# versions, use the standard constructor injection.

public class MyService
{
    private readonly IRedisCacheService _cache;

    public MyService(IRedisCacheService cache)
    {
        _cache = cache;
    }

    public async Task DoWorkAsync()
    {
        await _cache.SetAsync("user:123", new { Name = "John" }, TimeSpan.FromHours(1));
        var user = await _cache.GetAsync<dynamic>("user:123");
    }
}
Minimal API Usage
app.MapGet("/cache/{id}", async (string id, IRedisCacheService cache) => 
{
    return await cache.GetAsync<object>(id);
});

Configuration Options

Option Type Default Description
ConnectionString string null Required. Your Redis connection string.
InstanceName string "" Optional prefix for all keys (e.g. Dev:, Prod:).
DefaultExpiry TimeSpan 24 Hours Default cache duration for objects.
ThrowOnError bool true Whether to propagate Redis exceptions or fail gracefully.

Resilience and Fault Tolerance

This library handles connection pooling and self-healing. If Redis becomes temporarily unavailable or if a connection timeout occurs in Azure, the library will:

  1. Log the error via ILogger.
  2. Attempt automatic retries for transient failures.
  3. Automatically re-create the ConnectionMultiplexer if errors persist (Force Reconnect pattern).

Developed by Marimuthu Kandasamy (BigInt Technical Systems)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.0.2 94 3/9/2026
2.0.0 96 3/9/2026
1.0.1 546 9/22/2021
1.0.0 456 9/22/2021

Integrated Embedded Icon, SourceLink for debugging, and corrected symbols package alignment.