Browse Source

fix(localization): Fix the potential stamp cache expiration null reference exception

pull/1216/head
colin 8 months ago
parent
commit
25d7281209
  1. 5
      aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs

5
aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs

@ -84,14 +84,15 @@ public class ExternalLocalizationTextStoreCache : IExternalLocalizationTextStore
var stampCacheKey = ExternalLocalizationTextStampCacheItem.CalculateCacheKey(resource.ResourceName, cultureName);
var stampCacheItem = await StampCache.GetAsync(stampCacheKey);
if (memoryCacheItem != null && memoryCacheItem.CacheStamp == stampCacheItem.Stamp)
if (memoryCacheItem != null && memoryCacheItem.CacheStamp == stampCacheItem?.Stamp)
{
memoryCacheItem.LastCheckTime = DateTime.Now;
return memoryCacheItem.Texts;
}
var distributeCacheItem = await DistributedCache.GetAsync(cacheKey);
if (distributeCacheItem != null)
if (stampCacheItem != null && distributeCacheItem != null)
{
MemoryCache[cacheKey] = new LocalizationTextMemoryCacheItem(distributeCacheItem.Texts, stampCacheItem.Stamp);

Loading…
Cancel
Save