using Nop.Core.Caching; using Nop.Core.Domain.Catalog; using Nop.Core.Domain.Orders; using Nop.Services.Caching; using Nop.Services.Discounts; namespace Nop.Services.Catalog.Caching; /// /// Represents a product cache event consumer /// public partial class ProductCacheEventConsumer : CacheEventConsumer { /// /// Clear cache data /// /// Entity /// Entity event type /// A task that represents the asynchronous operation protected override async Task ClearCacheAsync(Product entity, EntityEventType entityEventType) { await RemoveByPrefixAsync(NopCatalogDefaults.ProductManufacturersByProductPrefix, entity); await RemoveAsync(NopCatalogDefaults.ProductsHomepageCacheKey); await RemoveByPrefixAsync(NopCatalogDefaults.ProductPricePrefix, entity); await RemoveByPrefixAsync(NopCatalogDefaults.ProductMultiplePricePrefix, entity); await RemoveByPrefixAsync(NopEntityCacheDefaults.AllPrefix); await RemoveByPrefixAsync(NopCatalogDefaults.FeaturedProductIdsPrefix); if (entityEventType == EntityEventType.Delete) { await RemoveByPrefixAsync(NopCatalogDefaults.FilterableSpecificationAttributeOptionsPrefix); await RemoveByPrefixAsync(NopCatalogDefaults.ManufacturersByCategoryPrefix); } await RemoveAsync(NopDiscountDefaults.AppliedDiscountsCacheKey, nameof(Product), entity); await base.ClearCacheAsync(entity, entityEventType); } }