MireaBackend/Endpoint/Configuration/ApplicationConfiguration/CacheConfiguration.cs

24 lines
818 B
C#
Raw Normal View History

2024-06-01 10:53:21 +03:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2024-07-04 23:54:17 +03:00
using Mirea.Api.Endpoint.Common.Settings;
2024-06-01 10:53:21 +03:00
using Mirea.Api.Endpoint.Configuration.General.Settings;
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
2024-06-01 10:53:21 +03:00
public static class CacheConfiguration
{
public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration)
{
2024-06-01 11:10:42 +03:00
var cache = configuration.Get<GeneralConfig>()?.CacheSettings;
2024-06-01 10:53:21 +03:00
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
{
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = cache.ConnectionString;
options.InstanceName = "mirea_";
});
}
return services;
}
}