|
|
@ -14,6 +14,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Client; |
|
|
|
|
|
|
|
|
public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency |
|
|
public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency |
|
|
{ |
|
|
{ |
|
|
|
|
|
private const string ApplicationConfigurationDtoCacheKey = "ApplicationConfigurationDto_CacheKey"; |
|
|
|
|
|
|
|
|
protected IHttpContextAccessor HttpContextAccessor { get; } |
|
|
protected IHttpContextAccessor HttpContextAccessor { get; } |
|
|
protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } |
|
|
protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; } |
|
|
protected AbpApplicationLocalizationClientProxy ApplicationLocalizationClientProxy { get; } |
|
|
protected AbpApplicationLocalizationClientProxy ApplicationLocalizationClientProxy { get; } |
|
|
@ -42,8 +44,21 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu |
|
|
|
|
|
|
|
|
public virtual async Task<ApplicationConfigurationDto> GetAsync() |
|
|
public virtual async Task<ApplicationConfigurationDto> GetAsync() |
|
|
{ |
|
|
{ |
|
|
var cacheKey = await CreateCacheKeyAsync(); |
|
|
string? cacheKey = null; |
|
|
var httpContext = HttpContextAccessor?.HttpContext; |
|
|
var httpContext = HttpContextAccessor?.HttpContext; |
|
|
|
|
|
if (httpContext != null && httpContext.Items[ApplicationConfigurationDtoCacheKey] is string key) |
|
|
|
|
|
{ |
|
|
|
|
|
cacheKey = key; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (cacheKey.IsNullOrWhiteSpace()) |
|
|
|
|
|
{ |
|
|
|
|
|
cacheKey = await CreateCacheKeyAsync(); |
|
|
|
|
|
if (httpContext != null) |
|
|
|
|
|
{ |
|
|
|
|
|
httpContext.Items[ApplicationConfigurationDtoCacheKey] = cacheKey; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) |
|
|
if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) |
|
|
{ |
|
|
{ |
|
|
@ -90,8 +105,21 @@ public class MvcCachedApplicationConfigurationClient : ICachedApplicationConfigu |
|
|
|
|
|
|
|
|
public ApplicationConfigurationDto Get() |
|
|
public ApplicationConfigurationDto Get() |
|
|
{ |
|
|
{ |
|
|
var cacheKey = AsyncHelper.RunSync(CreateCacheKeyAsync); |
|
|
string? cacheKey = null; |
|
|
var httpContext = HttpContextAccessor?.HttpContext; |
|
|
var httpContext = HttpContextAccessor?.HttpContext; |
|
|
|
|
|
if (httpContext != null && httpContext.Items[ApplicationConfigurationDtoCacheKey] is string key) |
|
|
|
|
|
{ |
|
|
|
|
|
cacheKey = key; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (cacheKey.IsNullOrWhiteSpace()) |
|
|
|
|
|
{ |
|
|
|
|
|
cacheKey = AsyncHelper.RunSync(CreateCacheKeyAsync); |
|
|
|
|
|
if (httpContext != null) |
|
|
|
|
|
{ |
|
|
|
|
|
httpContext.Items[ApplicationConfigurationDtoCacheKey] = cacheKey; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) |
|
|
if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration) |
|
|
{ |
|
|
{ |
|
|
|