From eefb049e0e22efdb358df16f5bac86daa001c64a Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Wed, 29 May 2024 03:35:52 +0300 Subject: [PATCH] feat: add cache for save intermediate settings --- .../Controllers/Configuration/SetupController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs index 4317b95..b629952 100644 --- a/Endpoint/Controllers/Configuration/SetupController.cs +++ b/Endpoint/Controllers/Configuration/SetupController.cs @@ -2,18 +2,28 @@ using System.Security.Cryptography; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; using Mirea.Api.Endpoint.Common.Attributes; using Mirea.Api.Endpoint.Common.Exceptions; using Mirea.Api.Endpoint.Common.Interfaces; +using Mirea.Api.Endpoint.Common.Services; using Mirea.Api.Endpoint.Configuration.General; +using Mirea.Api.Endpoint.Configuration.General.Settings; namespace Mirea.Api.Endpoint.Controllers.Configuration; [ApiVersion("1.0")] [ApiController] [MaintenanceModeIgnore] -public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigureService notConfigureService) : BaseController +public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigureService notConfigureService, IMemoryCache cache) : BaseController { + private const string CacheGeneralKey = "config_part"; + private GeneralConfig GeneralConfig +{ + get => cache.Get(CacheGeneralKey) ?? new GeneralConfig(); + set => cache.Set(CacheGeneralKey, value); + } + [HttpGet("GenerateToken")] [Localhost] public ActionResult GenerateToken()