|
|
|
@ -4,14 +4,16 @@ using Volo.Abp.Caching; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Domain.Entities.Events; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.EventBus.Local; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
|
|
|
|
namespace Volo.Abp.TenantManagement; |
|
|
|
|
|
|
|
|
|
|
|
[LocalEventHandlerOrder(-1)] |
|
|
|
public class TenantConfigurationCacheItemInvalidator : |
|
|
|
ILocalEventHandler<EntityChangedEventData<Tenant>>, |
|
|
|
ILocalEventHandler<EntityDeletedEventData<Tenant>>, ITransientDependency |
|
|
|
ILocalEventHandler<TenantChangedEvent>, |
|
|
|
ITransientDependency |
|
|
|
{ |
|
|
|
protected IDistributedCache<TenantConfigurationCacheItem> Cache { get; } |
|
|
|
|
|
|
|
@ -22,12 +24,17 @@ public class TenantConfigurationCacheItemInvalidator : |
|
|
|
|
|
|
|
public virtual async Task HandleEventAsync(EntityChangedEventData<Tenant> eventData) |
|
|
|
{ |
|
|
|
if (eventData is EntityCreatedEventData<Tenant>) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
await ClearCacheAsync(eventData.Entity.Id, eventData.Entity.NormalizedName); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task HandleEventAsync(EntityDeletedEventData<Tenant> eventData) |
|
|
|
public virtual async Task HandleEventAsync(TenantChangedEvent eventData) |
|
|
|
{ |
|
|
|
await ClearCacheAsync(eventData.Entity.Id, eventData.Entity.NormalizedName); |
|
|
|
await ClearCacheAsync(eventData.Id, eventData.NormalizedName); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task ClearCacheAsync(Guid? id, string normalizedName) |
|
|
|
@ -37,6 +44,7 @@ public class TenantConfigurationCacheItemInvalidator : |
|
|
|
{ |
|
|
|
TenantConfigurationCacheItem.CalculateCacheKey(id, null), |
|
|
|
TenantConfigurationCacheItem.CalculateCacheKey(null, normalizedName), |
|
|
|
TenantConfigurationCacheItem.CalculateCacheKey(id, normalizedName), |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |