using Nop.Core.Caching; using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Configuration; using Nop.Core.Domain.Vendors; using Nop.Core.Events; using Nop.Services.Events; using Nop.Services.Plugins; namespace Nop.Web.Areas.Admin.Infrastructure.Cache; /// /// Model cache event consumer (used for caching of presentation layer models) /// public partial class ModelCacheEventConsumer : //settings IConsumer>, //categories IConsumer>, IConsumer>, IConsumer>, //manufacturers IConsumer>, IConsumer>, IConsumer>, //vendors IConsumer>, IConsumer>, IConsumer>, IConsumer { #region Fields protected readonly IStaticCacheManager _staticCacheManager; #endregion #region Ctor public ModelCacheEventConsumer(IStaticCacheManager staticCacheManager) { _staticCacheManager = staticCacheManager; } #endregion #region Methods /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { //clear models which depend on settings await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.OfficialNewsModelKey); //depends on AdminAreaSettings.HideAdvertisementsOnAdminArea } //categories /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityInsertedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.CategoriesListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.CategoriesListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityDeletedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.CategoriesListKey); } //manufacturers /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityInsertedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.ManufacturersListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.ManufacturersListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityDeletedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.ManufacturersListKey); } //vendors /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityInsertedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorsListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityUpdatedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorsListKey); } /// A task that represents the asynchronous operation public async Task HandleEventAsync(EntityDeletedEvent eventMessage) { await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorsListKey); } /// /// Handle plugin updated event /// /// Event /// A task that represents the asynchronous operation public async Task HandleEventAsync(PluginUpdatedEvent eventMessage) { await _staticCacheManager.RemoveByPrefixAsync(NopPluginDefaults.AdminNavigationPluginsPrefix); } #endregion }