Browse Source

Refactor cache key usage in MvcCachedApplicationConfigurationClient

pull/24495/head
maliming 1 month ago
parent
commit
c1d5856572
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 10
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClient.cs

10
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;
}
}

Loading…
Cancel
Save