mirror of https://github.com/abpframework/abp.git
12 changed files with 132 additions and 186 deletions
@ -1,16 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
|
|||
public static class TenantConfigurationCacheHelper |
|||
{ |
|||
public static string CreateCacheKey(string tenantName) |
|||
{ |
|||
return $"RemoteTenantStore_Name_{tenantName}"; |
|||
} |
|||
|
|||
public static string CreateCacheKey(Guid tenantId) |
|||
{ |
|||
return $"RemoteTenantStore_Id_{tenantId:N}"; |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.MultiTenancy; |
|||
|
|||
[Serializable] |
|||
[IgnoreMultiTenancy] |
|||
public class TenantConfigurationCacheItem |
|||
{ |
|||
private const string CacheKeyFormat = "i:{0},n:{1}"; |
|||
|
|||
public TenantConfiguration? Value { get; set; } |
|||
|
|||
public TenantConfigurationCacheItem() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public TenantConfigurationCacheItem(TenantConfiguration? value) |
|||
{ |
|||
Value = value; |
|||
} |
|||
|
|||
public static string CalculateCacheKey(Guid? id, string? name) |
|||
{ |
|||
if (id == null && name.IsNullOrWhiteSpace()) |
|||
{ |
|||
throw new AbpException("Both id and name can't be invalid."); |
|||
} |
|||
return string.Format(CacheKeyFormat, |
|||
id?.ToString() ?? "null", |
|||
(name.IsNullOrWhiteSpace() ? "null" : name)); |
|||
} |
|||
|
|||
public static string CalculateCacheKey(Guid id) |
|||
{ |
|||
return string.Format(CacheKeyFormat, id.ToString(), "null" ); |
|||
} |
|||
|
|||
public static string CalculateCacheKey(string name) |
|||
{ |
|||
return string.Format(CacheKeyFormat, "null", name); |
|||
} |
|||
} |
|||
@ -1,35 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.TenantManagement; |
|||
|
|||
[Serializable] |
|||
[IgnoreMultiTenancy] |
|||
public class TenantCacheItem |
|||
{ |
|||
private const string CacheKeyFormat = "i:{0},n:{1}"; |
|||
|
|||
public TenantConfiguration Value { get; set; } |
|||
|
|||
public TenantCacheItem() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public TenantCacheItem(TenantConfiguration value) |
|||
{ |
|||
Value = value; |
|||
} |
|||
|
|||
public static string CalculateCacheKey(Guid? id, string name) |
|||
{ |
|||
if (id == null && name.IsNullOrWhiteSpace()) |
|||
{ |
|||
throw new AbpException("Both id and name can't be invalid."); |
|||
} |
|||
|
|||
return string.Format(CacheKeyFormat, |
|||
id?.ToString() ?? "null", |
|||
(name.IsNullOrWhiteSpace() ? "null" : name)); |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace Volo.Abp.TenantManagement; |
|||
|
|||
public class TenantCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<Tenant>>, ITransientDependency |
|||
{ |
|||
protected IDistributedCache<TenantCacheItem> Cache { get; } |
|||
|
|||
public TenantCacheItemInvalidator(IDistributedCache<TenantCacheItem> cache) |
|||
{ |
|||
Cache = cache; |
|||
} |
|||
|
|||
public virtual async Task HandleEventAsync(EntityChangedEventData<Tenant> eventData) |
|||
{ |
|||
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(eventData.Entity.Id, null), considerUow: true); |
|||
await Cache.RemoveAsync(TenantCacheItem.CalculateCacheKey(null, eventData.Entity.Name), considerUow: true); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue