Browse Source

Check cache value is not null.

pull/19056/head
maliming 3 years ago
parent
commit
6653691a96
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 10
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs
  2. 4
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs

10
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs

@ -40,9 +40,9 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency
} }
var tenantConfiguration = await Cache.GetAsync(cacheKey); var tenantConfiguration = await Cache.GetAsync(cacheKey);
if (tenantConfiguration == null) if (tenantConfiguration?.Value == null)
{ {
await TenantAppService.FindTenantByNameAsync(normalizedName); var tenant = await TenantAppService.FindTenantByNameAsync(normalizedName);
tenantConfiguration = await Cache.GetAsync(cacheKey); tenantConfiguration = await Cache.GetAsync(cacheKey);
} }
@ -65,7 +65,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency
} }
var tenantConfiguration = await Cache.GetAsync(cacheKey); var tenantConfiguration = await Cache.GetAsync(cacheKey);
if (tenantConfiguration == null) if (tenantConfiguration?.Value == null)
{ {
await TenantAppService.FindTenantByIdAsync(id); await TenantAppService.FindTenantByIdAsync(id);
tenantConfiguration = await Cache.GetAsync(cacheKey); tenantConfiguration = await Cache.GetAsync(cacheKey);
@ -90,7 +90,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency
} }
var tenantConfiguration = Cache.Get(cacheKey); var tenantConfiguration = Cache.Get(cacheKey);
if (tenantConfiguration == null) if (tenantConfiguration?.Value == null)
{ {
AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByNameAsync(normalizedName)); AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByNameAsync(normalizedName));
tenantConfiguration = Cache.Get(cacheKey); tenantConfiguration = Cache.Get(cacheKey);
@ -115,7 +115,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency
} }
var tenantConfiguration = Cache.Get(cacheKey); var tenantConfiguration = Cache.Get(cacheKey);
if (tenantConfiguration == null) if (tenantConfiguration?.Value == null)
{ {
AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByIdAsync(id)); AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByIdAsync(id));
tenantConfiguration = Cache.Get(cacheKey); tenantConfiguration = Cache.Get(cacheKey);

4
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs

@ -54,7 +54,7 @@ public class TenantStore : ITenantStore, ITransientDependency
var cacheKey = CalculateCacheKey(id, normalizedName); var cacheKey = CalculateCacheKey(id, normalizedName);
var cacheItem = await Cache.GetAsync(cacheKey, considerUow: true); var cacheItem = await Cache.GetAsync(cacheKey, considerUow: true);
if (cacheItem != null) if (cacheItem?.Value != null)
{ {
return cacheItem; return cacheItem;
} }
@ -94,7 +94,7 @@ public class TenantStore : ITenantStore, ITransientDependency
var cacheKey = CalculateCacheKey(id, normalizedName); var cacheKey = CalculateCacheKey(id, normalizedName);
var cacheItem = Cache.Get(cacheKey, considerUow: true); var cacheItem = Cache.Get(cacheKey, considerUow: true);
if (cacheItem != null) if (cacheItem?.Value != null)
{ {
return cacheItem; return cacheItem;
} }

Loading…
Cancel
Save