1
This commit is contained in:
20
Yes.Application/Admins/Articles/ArticleAddedEventHandler.cs
Normal file
20
Yes.Application/Admins/Articles/ArticleAddedEventHandler.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Yes.Application.Admins.Articles
|
||||
{
|
||||
public record ArticleAddedEvent(int ArticleId) : INotification;
|
||||
|
||||
|
||||
public class ArticleAddedEventHandler(BlogDbContext db, IMemoryCache cache) : INotificationHandler<ArticleAddedEvent>
|
||||
{
|
||||
private readonly BlogDbContext _db = db;
|
||||
private readonly IMemoryCache _cache = cache;
|
||||
public async Task Handle(ArticleAddedEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var articleId = notification.ArticleId;
|
||||
|
||||
_cache.Remove("Archives");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user