You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
980 B
39 lines
980 B
using Application.Domain.Entities;
|
|
using Infrastructure.Events;
|
|
using Microsoft.Extensions.Caching.Distributed;
|
|
|
|
namespace IoTNode.Services
|
|
{
|
|
public class CacheEventHandler :
|
|
IEventHander<EntityInsertedEvent<SceneTigger>>,
|
|
IEventHander<EntityUpdatedEvent<SceneTigger>>,
|
|
IEventHander<EntityDeletedEvent<SceneTigger>>
|
|
{
|
|
private readonly IDistributedCache _cache;
|
|
|
|
public CacheEventHandler(IDistributedCache cache)
|
|
{
|
|
this._cache = cache;
|
|
}
|
|
|
|
public void Handle(EntityInsertedEvent<SceneTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
public void Handle(EntityUpdatedEvent<SceneTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
public void Handle(EntityDeletedEvent<SceneTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
private void Remove()
|
|
{
|
|
this._cache.Remove(CacheKey.SceneTiggerKey);
|
|
}
|
|
}
|
|
} |