Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

DiscountRequirementCacheEventConsumer.cs

using Nop.Core.Domain.Discounts;
using Nop.Services.Caching;

namespace Nop.Services.Discounts.Caching;

/// 
/// Represents a discount requirement cache event consumer
/// 
public partial class DiscountRequirementCacheEventConsumer : CacheEventConsumer
{
    /// 
    /// Clear cache data
    /// 
    /// Entity
    /// A task that represents the asynchronous operation
    protected override async Task ClearCacheAsync(DiscountRequirement entity)
    {
        await RemoveAsync(NopDiscountDefaults.DiscountRequirementsByDiscountCacheKey, entity.DiscountId);

        if (entity.ParentId.HasValue)
            await RemoveAsync(NopDiscountDefaults.DiscountRequirementsByParentCacheKey, entity.ParentId);
    }

    /// 
    /// Clear cache by entity event type
    /// 
    /// Entity
    /// Entity event type
    /// A task that represents the asynchronous operation
    protected override async Task ClearCacheAsync(DiscountRequirement entity, EntityEventType entityEventType)
    {
        if (entityEventType == EntityEventType.Delete)
            await RemoveAsync(NopDiscountDefaults.DiscountRequirementsByParentCacheKey, entity);

        await base.ClearCacheAsync(entity, entityEventType);
    }
}