diff --git a/Endpoint/Configuration/AppConfig/CacheConfiguration.cs b/Endpoint/Configuration/AppConfig/CacheConfiguration.cs new file mode 100644 index 0000000..7a1954c --- /dev/null +++ b/Endpoint/Configuration/AppConfig/CacheConfiguration.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Mirea.Api.Endpoint.Configuration.General.Settings; + +namespace Mirea.Api.Endpoint.Configuration.AppConfig; + +public static class CacheConfiguration +{ + public static IServiceCollection AddCustomRedis(this IServiceCollection services, IConfiguration configuration) + { + var cache = configuration.Get(); + if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis) + { + services.AddStackExchangeRedisCache(options => + { + options.Configuration = cache.ConnectionString; + options.InstanceName = "mirea_"; + }); + } + + return services; + } +} \ No newline at end of file diff --git a/Endpoint/Endpoint.csproj b/Endpoint/Endpoint.csproj index 26fc0a3..bb33b99 100644 --- a/Endpoint/Endpoint.csproj +++ b/Endpoint/Endpoint.csproj @@ -29,6 +29,7 @@ +