Browse Source
Merge pull request #694 from colinin/upt-5.3.4
different tenant cache keys may exist
pull/712/head
yx lin
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
13 deletions
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs
-
aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/TenantCacheItemInvalidator.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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -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); |
|
|
|
|