Try your search with a different keyword or use * as a wildcard.
using Nop.Core.Caching;
using Nop.Core.Domain.Blogs;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Configuration;
using Nop.Core.Domain.Localization;
using Nop.Core.Domain.Media;
using Nop.Core.Domain.News;
using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Polls;
using Nop.Core.Domain.Topics;
using Nop.Core.Domain.Vendors;
using Nop.Core.Events;
using Nop.Services.Cms;
using Nop.Services.Events;
using Nop.Services.Plugins;
using Nop.Web.Framework.Models.Cms;
namespace Nop.Web.Infrastructure.Cache;
///
/// Model cache event consumer (used for caching of presentation layer models)
///
public partial class ModelCacheEventConsumer :
//languages
IConsumer>,
IConsumer>,
IConsumer>,
//settings
IConsumer>,
//manufacturers
IConsumer>,
IConsumer>,
IConsumer>,
//vendors
IConsumer>,
IConsumer>,
IConsumer>,
//categories
IConsumer>,
IConsumer>,
IConsumer>,
//product categories
IConsumer>,
IConsumer>,
//products
IConsumer>,
IConsumer>,
IConsumer>,
//product tags
IConsumer>,
IConsumer>,
IConsumer>,
//Product attribute values
IConsumer>,
//Topics
IConsumer>,
IConsumer>,
IConsumer>,
//Orders
IConsumer>,
IConsumer>,
IConsumer>,
//Picture
IConsumer>,
IConsumer>,
IConsumer>,
//Product picture mapping
IConsumer>,
IConsumer>,
IConsumer>,
//Product review
IConsumer>,
//polls
IConsumer>,
IConsumer>,
IConsumer>,
//blog posts
IConsumer>,
IConsumer>,
IConsumer>,
//news items
IConsumer>,
IConsumer>,
IConsumer>,
//shopping cart items
IConsumer>,
//plugins
IConsumer
{
#region Fields
protected readonly CatalogSettings _catalogSettings;
protected readonly IStaticCacheManager _staticCacheManager;
#endregion
#region Ctor
public ModelCacheEventConsumer(CatalogSettings catalogSettings, IStaticCacheManager staticCacheManager)
{
_staticCacheManager = staticCacheManager;
_catalogSettings = catalogSettings;
}
#endregion
#region Methods
#region Languages
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
//clear all localizable models
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
//clear all localizable models
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
//clear all localizable models
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
}
#endregion
#region Setting
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
//clear models which depend on settings
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey); //depends on CatalogSettings.ManufacturersBlockItemsToDisplay
await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorNavigationModelKey); //depends on VendorSettings.VendorBlockItemsToDisplay
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey); //depends on CatalogSettings.ShowCategoryProductNumber and CatalogSettings.ShowCategoryProductNumberIncludingSubcategories
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey); //depends on CatalogSettings.NumberOfBestsellersOnHomepage
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey); //depends on CatalogSettings.ProductsAlsoPurchasedNumber
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.BlogPrefixCacheKey); //depends on BlogSettings.NumberOfTags
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.NewsPrefixCacheKey); //depends on NewsSettings.MainPageNewsCount
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey); //depends on distinct sitemap settings
await _staticCacheManager.RemoveByPrefixAsync(WidgetModelDefaults.WidgetPrefixCacheKey); //depends on WidgetSettings and certain settings of widgets
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.StoreLogoPathPrefixCacheKey); //depends on StoreInformationSettings.LogoPictureId
}
#endregion
#region Vendors
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorNavigationModelKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorNavigationModelKey);
await _staticCacheManager.RemoveByPrefixAsync(string.Format(NopModelCacheDefaults.VendorPicturePrefixCacheKeyById, eventMessage.Entity.Id));
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveAsync(NopModelCacheDefaults.VendorNavigationModelKey);
}
#endregion
#region Manufacturers
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(string.Format(NopModelCacheDefaults.ManufacturerPicturePrefixCacheKeyById, eventMessage.Entity.Id));
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ManufacturerNavigationPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
#endregion
#region Categories
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryHomepagePrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryHomepagePrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(string.Format(NopModelCacheDefaults.CategoryPicturePrefixCacheKeyById, eventMessage.Entity.Id));
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryHomepagePrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
#endregion
#region Product categories
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
if (_catalogSettings.ShowCategoryProductNumber)
{
//depends on CatalogSettings.ShowCategoryProductNumber (when enabled)
//so there's no need to clear this cache in other cases
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
}
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
if (_catalogSettings.ShowCategoryProductNumber)
{
//depends on CatalogSettings.ShowCategoryProductNumber (when enabled)
//so there's no need to clear this cache in other cases
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryAllPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.CategoryXmlAllPrefixCacheKey);
}
}
#endregion
#region Products
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(string.Format(NopModelCacheDefaults.ProductReviewsPrefixCacheKeyById, eventMessage.Entity.Id));
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
#endregion
#region Product tags
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
#endregion
#region Product attributes
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductAttributePicturePrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductAttributeImageSquarePicturePrefixCacheKey);
}
#endregion
#region Topics
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.SitemapPrefixCacheKey);
}
#endregion
#region Orders
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityUpdatedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey);
}
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityDeletedEvent eventMessage)
{
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.HomepageBestsellersIdsPrefixCacheKey);
await _staticCacheManager.RemoveByPrefixAsync(NopModelCacheDefaults.ProductsAlsoPurchasedIdsPrefixCacheKey);
}
#endregion
#region Pictures
/// A task that represents the asynchronous operation
public async Task HandleEventAsync(EntityInsertedEvent