added IEventSubscriber amd EventDistributorHostedService to optimize event processing
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Infrastructure.EventSubscribers
|
||||
{
|
||||
public class CacheInvalidationEventSubscriber : IEventSubscriber
|
||||
{
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public CacheInvalidationEventSubscriber(IMemoryCache cache)
|
||||
{
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
public void EntityChanged(SyncEvent syncEvent)
|
||||
{
|
||||
if (syncEvent.EntityName == "Site" && syncEvent.Action == SyncEventActions.Refresh)
|
||||
{
|
||||
_cache.Remove($"site:{syncEvent.TenantId}:{syncEvent.EntityId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user