From b8ab7948a991226d9cc5f88c11dd117b12458852 Mon Sep 17 00:00:00 2001 From: Ricardo Carneiro Date: Sun, 24 Aug 2025 23:30:45 -0300 Subject: [PATCH] fix: cache --- Program.cs | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/Program.cs b/Program.cs index da65e3c..0a0cbfa 100644 --- a/Program.cs +++ b/Program.cs @@ -20,6 +20,7 @@ using Serilog.Events; using Serilog.Sinks.SystemConsole.Themes; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.AspNetCore.DataProtection; var builder = WebApplication.CreateBuilder(args); @@ -81,30 +82,14 @@ else builder.Services.AddScoped(); } -// Cache Configuration - use Redis if available, otherwise memory cache -var redisConnectionString = builder.Configuration.GetConnectionString("Redis"); -if (!string.IsNullOrEmpty(redisConnectionString)) -{ - try - { - builder.Services.AddStackExchangeRedisCache(options => - { - options.Configuration = redisConnectionString; - }); - } - catch - { - // Fallback to memory cache if Redis fails - builder.Services.AddMemoryCache(); - builder.Services.AddSingleton(); - } -} -else -{ - // Use memory cache when Redis is not configured - builder.Services.AddMemoryCache(); - builder.Services.AddSingleton(); -} +builder.Services.AddMemoryCache(); +builder.Services.AddSingleton(); + +// ✅ DataProtection compartilhado via FileSystem (ADICIONAR APÓS O CACHE) +builder.Services.AddDataProtection() + .PersistKeysToFileSystem(new DirectoryInfo("/app/keys")) + .SetApplicationName("QRRapido"); + // Authentication Configuration builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)