Pdsr.HealthChecks.Redis 2.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pdsr.HealthChecks.Redis --version 2.2.1                
NuGet\Install-Package Pdsr.HealthChecks.Redis -Version 2.2.1                
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="Pdsr.HealthChecks.Redis" Version="2.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pdsr.HealthChecks.Redis --version 2.2.1                
#r "nuget: Pdsr.HealthChecks.Redis, 2.2.1"                
#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.
// Install Pdsr.HealthChecks.Redis as a Cake Addin
#addin nuget:?package=Pdsr.HealthChecks.Redis&version=2.2.1

// Install Pdsr.HealthChecks.Redis as a Cake Tool
#tool nuget:?package=Pdsr.HealthChecks.Redis&version=2.2.1                

Pdsr HealthChecks Libraries

Contains HealthChecks for OpenId-Connect, RedisCacheManager, Postgres, and RabbitMQ.

Getting Started

Health checks need to register in the DI container.

Redis Healthcheck

In the minimal API, use builder.Services to add the extension method, AddRedisCacheManager to IHealthChecksBuilder.

var degradedThreshold = 50;     // in milliseconds, response time higher than 50 will be considered degraded
var unhealthyThreshold = 100;   // in milliseconds, response time higher than 100 will be considered unhealthy
builder.Services.AddHealthChecks()
    .AddRedisCacheManager(degradedThreshold,unhealthyThreshold);

Memory HealthCheck

You can define a memory usage limit for the MemoryHealthCheck

In the minimal API, use builder.Services to add the extension method, AddMemoryHealthCheck to IHealthChecksBuilder

builder.Services.AddHealthChecks()
    .AddMemoryHealthCheck(
        degradedThreshold: 50 * 1024L * 1024L,      // shows degraded at this 50 MB
        unhealthyThreshold: 100 * 2048L * 2048L,    // threshold to show failureStatus (unhealthy), 100MB
        failureStatus: HealthStatus.Unhealthy,      // default failure status is HealthStatus.Unhealthy
        tags: new string[] { "memory", "ram" });    // optional tags

Health Publisher

The interface ISystemHealth and the abstract class SystemHealthBase are available to be used as publisher.

you need to inherit from SystemHealthBase:

public class MyHealthStatus : SystemHealthBase
{
    // some custom properties
}

Register in DI container

builder.Services.RegisterReadinessPublisher<MyHealthStatus>();

The instance of MyHealthStatus is available through injection.

public class SomeService : ISomeService
{
    private readonly MySystemHealth _mySystemHealth;
    public SomeService(MySystemHealth mySystemHealth)
    {
        _mySystemHealth = _mySystemHealth;
    }

    public void SomeMethod()
    {
        var health = _mySystemHealth.HealthReport;
        // do whatever you like with that health status.
    }
}

Samples

Refer to the samples folder.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
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.3.0 732 2/20/2024
2.2.1 176 9/17/2023
2.2.0 165 8/30/2023
2.1.1 300 2/20/2023
2.1.0 2,564 11/11/2022
2.0.2 371 8/26/2022
2.0.1 461 5/11/2022
2.0.1-preview.1.254 335 4/18/2022
2.0.0 419 5/11/2022