2026-02-24 20:44:16 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Sozsoft.Languages.Entities;
|
2026-10-05 12:58:59 +00:00
|
|
|
|
using Sozsoft.Languages.Localization;
|
2026-02-24 20:44:16 +00:00
|
|
|
|
using Volo.Abp.Caching;
|
|
|
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
|
|
using Volo.Abp.Domain.Entities.Events;
|
|
|
|
|
|
using Volo.Abp.EventBus;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Sozsoft.Languages;
|
|
|
|
|
|
|
|
|
|
|
|
public class LanguageTextCacheItemInvalidator :
|
|
|
|
|
|
ILocalEventHandler<EntityChangedEventData<LanguageText>>,
|
|
|
|
|
|
ITransientDependency
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IDistributedCache<LanguageTextCacheItem> cache;
|
2026-10-05 12:58:59 +00:00
|
|
|
|
private readonly IDatabaseResourceLocalizer localizer;
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
2026-10-05 12:58:59 +00:00
|
|
|
|
public LanguageTextCacheItemInvalidator(IDistributedCache<LanguageTextCacheItem> cache, IDatabaseResourceLocalizer localizer)
|
2026-02-24 20:44:16 +00:00
|
|
|
|
{
|
|
|
|
|
|
this.cache = cache;
|
2026-10-05 12:58:59 +00:00
|
|
|
|
this.localizer = localizer;
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task HandleEventAsync(EntityChangedEventData<LanguageText> eventData)
|
|
|
|
|
|
{
|
|
|
|
|
|
//distributedCacheOptions.Value.KeyPrefix
|
|
|
|
|
|
var key = LanguageTextCacheItem.CalculateCacheKey(eventData.Entity.ResourceName, eventData.Entity.CultureName);
|
|
|
|
|
|
await cache.RemoveAsync(key);
|
2026-10-05 12:58:59 +00:00
|
|
|
|
localizer.ClearLocalCache();
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|