Browse Source

Merge pull request #1216 from colinin/fix-localization-stamp-cache

fix(localization): Fix the potential stamp cache expiration null reference exception
pull/1238/head
yx lin 1 year ago
committed by GitHub
parent
commit
daf7886b50
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  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