diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs index 84ce9f988..055480eaf 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs +++ b/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); } } diff --git a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs index 617abb778..d6f365171 100644 --- a/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs +++ b/aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.cs @@ -18,6 +18,9 @@ public class TenantCacheItemInvalidator : ILocalEventHandler 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);