feat: add redis
This commit is contained in:
parent
34addd930f
commit
f3a757d33d
23
Endpoint/Configuration/AppConfig/CacheConfiguration.cs
Normal file
23
Endpoint/Configuration/AppConfig/CacheConfiguration.cs
Normal file
@ -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<CacheSettings>();
|
||||||
|
if (cache?.TypeDatabase == CacheSettings.CacheEnum.Redis)
|
||||||
|
{
|
||||||
|
services.AddStackExchangeRedisCache(options =>
|
||||||
|
{
|
||||||
|
options.Configuration = cache.ConnectionString;
|
||||||
|
options.InstanceName = "mirea_";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@
|
|||||||
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.6" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Versioning" Version="2.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Versioning" Version="2.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user