24 lines
815 B
C#
24 lines
815 B
C#
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)
|
|
{
|
|
var cache = configuration.Get<GeneralConfig>()?.CacheSettings;
|
|
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
|
|
{
|
|
services.AddStackExchangeRedisCache(options =>
|
|
{
|
|
options.Configuration = cache.ConnectionString;
|
|
options.InstanceName = "mirea_";
|
|
});
|
|
}
|
|
|
|
return services;
|
|
}
|
|
} |