mirror of https://github.com/abpframework/abp.git
6 changed files with 64 additions and 4 deletions
@ -0,0 +1,13 @@ |
|||
using System.Globalization; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Client |
|||
{ |
|||
internal static class MvcCachedApplicationConfigurationClientHelper |
|||
{ |
|||
public static string CreateCacheKey(ICurrentUser currentUser) |
|||
{ |
|||
return $"ApplicationConfiguration_{currentUser.Id?.ToString("N") ?? "Anonymous"}_{CultureInfo.CurrentUICulture.Name}"; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Client |
|||
{ |
|||
public class MvcCurrentApplicationConfigurationCacheResetEventHandler : |
|||
ILocalEventHandler<CurrentApplicationConfigurationCacheResetEventData>, |
|||
ITransientDependency |
|||
{ |
|||
protected ICurrentUser CurrentUser { get; } |
|||
protected IDistributedCache<ApplicationConfigurationDto> Cache { get; } |
|||
|
|||
public MvcCurrentApplicationConfigurationCacheResetEventHandler(ICurrentUser currentUser, |
|||
IDistributedCache<ApplicationConfigurationDto> cache) |
|||
{ |
|||
CurrentUser = currentUser; |
|||
Cache = cache; |
|||
} |
|||
|
|||
public virtual async Task HandleEventAsync(CurrentApplicationConfigurationCacheResetEventData eventData) |
|||
{ |
|||
await Cache.RemoveAsync(CreateCacheKey()); |
|||
} |
|||
|
|||
protected virtual string CreateCacheKey() |
|||
{ |
|||
return MvcCachedApplicationConfigurationClientHelper.CreateCacheKey(CurrentUser); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations |
|||
{ |
|||
/// <summary>
|
|||
/// This event is used to invalidate current user's cached configuration.
|
|||
/// </summary>
|
|||
public class CurrentApplicationConfigurationCacheResetEventData |
|||
{ |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue