Browse Source

different tenant cache keys may exist

pull/694/head
cKey 3 years ago
parent
commit
96c6bce9b3
  1. 21
      aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs
  2. 3
      aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs

21
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs

@ -1,7 +1,4 @@
using LINGYUN.Abp.MultiTenancy;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
@ -22,19 +19,17 @@ public class ConnectionStringInvalidator :
public async virtual Task HandleEventAsync(ConnectionStringCreatedEventData eventData)
{
await Cache.RemoveAsync(
TenantCacheItem.CalculateCacheKey(
eventData.TenantId,
eventData.TenantName),
considerUow: true);
// 需要考虑三种情形下的缓存键
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(null, eventData.TenantName), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.TenantId, null), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.TenantId, eventData.TenantName), considerUow: true);
}
public async virtual Task HandleEventAsync(ConnectionStringDeletedEventData eventData)
{
await Cache.RemoveAsync(
TenantCacheItem.CalculateCacheKey(
eventData.TenantId,
eventData.TenantName),
considerUow: true);
// 需要考虑三种情形下的缓存键
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(null, eventData.TenantName), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.TenantId, null), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.TenantId, eventData.TenantName), considerUow: true);
}
}

3
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs

@ -18,6 +18,9 @@ public class TenantCacheItemInvalidator : ILocalEventHandler<EntityChangedEventD
public async virtual Task HandleEventAsync(EntityChangedEventData<Tenant> eventData)
{
// 需要考虑三种情形下的缓存键
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(null, eventData.Entity.Name), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.Entity.Id, null), considerUow: true);
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.Entity.Id, eventData.Entity.Name), considerUow: true);
// 同时移除租户版本缓存
await Cache.RemoveAsync(EditionCacheItem.CalculateCacheKey(eventData.Entity.Id), considerUow: true);

Loading…
Cancel
Save