24 lines
822 B
C#
24 lines
822 B
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Mirea.Api.Endpoint.Configuration.ConfigurationChecks.Settings;
|
|
using Mirea.Api.Endpoint.Configuration.Model;
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.Core.Startup;
|
|
|
|
public static class CacheConfiguration
|
|
{
|
|
public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
var cache = configuration.Get<GeneralConfig>()?.CacheSettings;
|
|
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
|
|
{
|
|
services.AddStackExchangeRedisCache(options =>
|
|
{
|
|
options.Configuration = cache.ConnectionString;
|
|
options.InstanceName = "mirea_";
|
|
});
|
|
}
|
|
|
|
return services;
|
|
}
|
|
} |