December 2019
Intermediate to advanced
510 pages
11h 33m
English
ASP.NET Core's health check feature is not only suitable for the data source of our service; it can also be used to perform sophisticated and custom health checks. The framework provides the IHealthCheck interface so that we can implement our health check. Let's create a new class called RedisCacheHealthCheck in the HealthCheck folder, inside the Catalog.API project:
using System;using System.Threading;using System.Threading.Tasks;using Microsoft.Extensions.Diagnostics.HealthChecks;using Microsoft.Extensions.Options;using StackExchange.Redis;using Catalog.Domain.Settings;namespace Catalog.API.HealthChecks{ public class RedisCacheHealthCheck : IHealthCheck { private readonly CacheSettings _settings; public ...