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.
40 lines
940 B
40 lines
940 B
using Infrastructure.Events;
|
|
using Application.Domain.Entities;
|
|
using Microsoft.Extensions.Caching.Distributed;
|
|
|
|
namespace Platform.Services
|
|
{
|
|
public class CacheEventHandler :
|
|
IEventHander<EntityInserted<IoTTigger>>,
|
|
IEventHander<EntityUpdated<IoTTigger>>,
|
|
IEventHander<EntityDeleted<IoTTigger>>
|
|
{
|
|
private readonly IDistributedCache _cache;
|
|
|
|
public CacheEventHandler(IDistributedCache cache)
|
|
{
|
|
this._cache = cache;
|
|
}
|
|
|
|
public void Handle(EntityInserted<IoTTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
public void Handle(EntityUpdated<IoTTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
public void Handle(EntityDeleted<IoTTigger> message)
|
|
{
|
|
this.Remove();
|
|
}
|
|
|
|
private void Remove()
|
|
{
|
|
this._cache.Remove(CacheKey.SceneTiggerKey);
|
|
}
|
|
}
|
|
}
|