Browse Source

fix(localization): Fixed with removed `AsyncKeyedLocker`

- 使用 `KeyedLock` 替代 `AsyncKeyedLocker`
pull/1416/head
colin 2 months ago
parent
commit
bb8cb9fe4a
  1. 12
      aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/External/ExternalLocalizationTextStoreCache.cs

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

@ -1,5 +1,4 @@
using AsyncKeyedLock;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@ -8,13 +7,13 @@ using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Localization;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace LINGYUN.Abp.LocalizationManagement.External;
public class ExternalLocalizationTextStoreCache : IExternalLocalizationTextStoreCache, ISingletonDependency
{
protected AsyncKeyedLocker<string> AsyncKeyedLocker;
protected ConcurrentDictionary<string, LocalizationTextMemoryCacheItem> MemoryCache { get; }
protected IAbpDistributedLock DistributedLock { get; }
@ -33,11 +32,6 @@ public class ExternalLocalizationTextStoreCache : IExternalLocalizationTextStore
DistributedCache = distributedCache;
StampCache = stampCache;
AsyncKeyedLocker = new AsyncKeyedLocker<string>(o =>
{
o.PoolSize = 20;
o.PoolInitialFill = 1;
});
MemoryCache = new ConcurrentDictionary<string, LocalizationTextMemoryCacheItem>();
}
@ -74,7 +68,7 @@ public class ExternalLocalizationTextStoreCache : IExternalLocalizationTextStore
return memoryCacheItem.Texts;
}
using (await AsyncKeyedLocker.LockAsync(cacheKey))
using (await KeyedLock.LockAsync(cacheKey))
{
memoryCacheItem = MemoryCache.GetOrDefault(cacheKey);
if (memoryCacheItem != null && !IsShouldCheck(memoryCacheItem))

Loading…
Cancel
Save