From c1d5856572cccf52c554c8495c66be2d11d8ab4f Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 29 Dec 2025 21:55:11 +0800 Subject: [PATCH] Refactor cache key usage in MvcCachedApplicationConfigurationClient --- .../Client/MvcCachedApplicationConfigurationClient.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs index b4e81c986a..e3d3c12370 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs @@ -14,6 +14,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Client; public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency { + private const string ApplicationConfigurationDtoCacheKey = "ApplicationConfigurationDto_CacheKey"; + protected IHttpContextAccessor HttpContextAccessor { get; } protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } protected AbpApplicationLocalizationClientProxy ApplicationLocalizationClientProxy { get; } @@ -44,7 +46,7 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu { string? cacheKey = null; var httpContext = HttpContextAccessor?.HttpContext; - if (httpContext != null && httpContext.Items["ApplicationConfigurationDto_CacheKey"] is string key) + if (httpContext != null && httpContext.Items[ApplicationConfigurationDtoCacheKey] is string key) { cacheKey = key; } @@ -54,7 +56,7 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu cacheKey = await CreateCacheKeyAsync(); if (httpContext != null) { - httpContext.Items["ApplicationConfigurationDto_CacheKey"] = cacheKey; + httpContext.Items[ApplicationConfigurationDtoCacheKey] = cacheKey; } } @@ -105,7 +107,7 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu { string? cacheKey = null; var httpContext = HttpContextAccessor?.HttpContext; - if (httpContext != null && httpContext.Items["ApplicationConfigurationDto_CacheKey"] is string key) + if (httpContext != null && httpContext.Items[ApplicationConfigurationDtoCacheKey] is string key) { cacheKey = key; } @@ -115,7 +117,7 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu cacheKey = AsyncHelper.RunSync(CreateCacheKeyAsync); if (httpContext != null) { - httpContext.Items["ApplicationConfigurationDto_CacheKey"] = cacheKey; + httpContext.Items[ApplicationConfigurationDtoCacheKey] = cacheKey; } }