From 6653691a96f1b210223632cacd9621d75a649796 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 16 Feb 2024 15:15:46 +0800 Subject: [PATCH] Check cache value is not null. --- .../Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs | 10 +++++----- .../Volo/Abp/TenantManagement/TenantStore.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs index 1bc7856ca6..dce80a3099 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcRemoteTenantStore.cs +++ b/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); - if (tenantConfiguration == null) + if (tenantConfiguration?.Value == null) { - await TenantAppService.FindTenantByNameAsync(normalizedName); + var tenant = await TenantAppService.FindTenantByNameAsync(normalizedName); tenantConfiguration = await Cache.GetAsync(cacheKey); } @@ -65,7 +65,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency } var tenantConfiguration = await Cache.GetAsync(cacheKey); - if (tenantConfiguration == null) + if (tenantConfiguration?.Value == null) { await TenantAppService.FindTenantByIdAsync(id); tenantConfiguration = await Cache.GetAsync(cacheKey); @@ -90,7 +90,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency } var tenantConfiguration = Cache.Get(cacheKey); - if (tenantConfiguration == null) + if (tenantConfiguration?.Value == null) { AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByNameAsync(normalizedName)); tenantConfiguration = Cache.Get(cacheKey); @@ -115,7 +115,7 @@ public class MvcRemoteTenantStore : ITenantStore, ITransientDependency } var tenantConfiguration = Cache.Get(cacheKey); - if (tenantConfiguration == null) + if (tenantConfiguration?.Value == null) { AsyncHelper.RunSync(async () => await TenantAppService.FindTenantByIdAsync(id)); tenantConfiguration = Cache.Get(cacheKey); diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs index d334c124a6..808a9684cd 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/TenantStore.cs +++ b/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 cacheItem = await Cache.GetAsync(cacheKey, considerUow: true); - if (cacheItem != null) + if (cacheItem?.Value != null) { return cacheItem; } @@ -94,7 +94,7 @@ public class TenantStore : ITenantStore, ITransientDependency var cacheKey = CalculateCacheKey(id, normalizedName); var cacheItem = Cache.Get(cacheKey, considerUow: true); - if (cacheItem != null) + if (cacheItem?.Value != null) { return cacheItem; }