using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Mirea.Api.Endpoint.Configuration.Model; using Mirea.Api.Endpoint.Configuration.Model.GeneralSettings; namespace Mirea.Api.Endpoint.Configuration.Core.Startup; public static class CacheConfiguration { public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration, IHealthChecksBuilder? healthChecksBuilder = null) { var cache = configuration.Get()?.CacheSettings; if (cache?.TypeDatabase != CacheSettings.CacheEnum.Redis) return services; services.AddStackExchangeRedisCache(options => { options.Configuration = cache.ConnectionString; options.InstanceName = "mirea_"; }); healthChecksBuilder?.AddRedis(cache.ConnectionString!, name: "Redis"); return services; } }