Browse Source

CmsKit - Use LocalEvent to Notify BlogFeature changes

pull/7845/head
enisn 6 years ago
parent
commit
589b464426
  1. 12
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs
  2. 5
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs

12
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs

@ -1,22 +1,22 @@
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Volo.Abp.EventBus.Distributed;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureChangedHandler : IDistributedEventHandler<BlogFeatureChangedEto>, ITransientDependency
public class BlogFeatureChangedHandler : ILocalEventHandler<BlogFeatureChangedEto>, ITransientDependency
{
protected IDistributedCache<BlogFeatureDto> Cache { get; }
protected IBlogFeatureCacheManager CacheManager { get; }
public BlogFeatureChangedHandler(IDistributedCache<BlogFeatureDto> cache)
public BlogFeatureChangedHandler(IBlogFeatureCacheManager cacheManager)
{
Cache = cache;
CacheManager = cacheManager;
}
public async Task HandleEventAsync(BlogFeatureChangedEto eventData)
{
await Cache.RemoveAsync($"{eventData.BlogId}_{eventData.FeatureName}");
await CacheManager.ClearAsync(eventData.BlogId, eventData.FeatureName);
}
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Uow;
namespace Volo.CmsKit.Blogs
@ -15,13 +16,13 @@ namespace Volo.CmsKit.Blogs
protected IUnitOfWorkManager UnitOfWorkManager { get; }
protected IDistributedEventBus EventBus { get; }
protected ILocalEventBus EventBus { get; }
public BlogFeatureManager(
IBlogFeatureRepository blogFeatureRepository,
IDefaultBlogFeatureProvider defaultBlogFeatureProvider,
IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus eventBus)
ILocalEventBus eventBus)
{
BlogFeatureRepository = blogFeatureRepository;
DefaultBlogFeatureProvider = defaultBlogFeatureProvider;

Loading…
Cancel
Save