add redis

This commit is contained in:
m.zargarov 2024-11-10 13:35:23 +04:00
parent 5d7beec9c1
commit a4dae6211f
3 changed files with 25 additions and 1 deletions

View File

@ -15,6 +15,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.7" />
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
</ItemGroup>

View File

@ -6,12 +6,20 @@ using System.Text;
using FluentValidation;
using FluentValidation.AspNetCore;
using Cloud.Validation;
using StackExchange.Redis;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
//Jwt configuration starts here
//Redis configuration
builder.Services.AddSingleton<IConnectionMultiplexer>(sp =>
{
var configuration = ConfigurationOptions.Parse("localhost:6379");
return ConnectionMultiplexer.Connect(configuration);
});
//Jwt configuration
var jwtIssuer = builder.Configuration.GetSection("Jwt:Issuer").Get<string>();
var jwtKey = builder.Configuration.GetSection("Jwt:Key").Get<string>();

View File

@ -11,6 +11,21 @@ services:
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: 'redis:latest'
ports:
- '6379:6379'
volumes:
- 'cloud-redis:/data'
healthcheck:
test:
- CMD
- redis-cli
- ping
retries: 3
timeout: 5s
volumes:
postgres_data:
driver: local
cloud-redis:
driver: local