using Nop.Core.Caching;
using Nop.Core.Domain.Configuration;
using Nop.Core.Events;
using Nop.Services.Events;
namespace Nop.Plugin.Widgets.NopCliGeneric.Infrastructure.Cache
{
///
/// Model cache event consumer (used for caching of presentation layer models)
///
public partial class ModelCacheEventConsumer :
IConsumer>,
IConsumer>,
IConsumer>
{
///
/// Key for caching
///
///
/// {0} : picture id
/// {1} : connection type (http/https)
///
public const string PICTURE_URL_PATTERN_KEY = "Nop.plugins.widgets.NopCliGeneric";
private readonly IStaticCacheManager _staticCacheManager;
public ModelCacheEventConsumer(IStaticCacheManager staticCacheManager)
{
_staticCacheManager = staticCacheManager;
}
public void HandleEvent(EntityInsertedEvent eventMessage)
{
_staticCacheManager.RemoveByPrefix(PICTURE_URL_PATTERN_KEY);
}
public void HandleEvent(EntityUpdatedEvent eventMessage)
{
_staticCacheManager.RemoveByPrefix(PICTURE_URL_PATTERN_KEY);
}
public void HandleEvent(EntityDeletedEvent eventMessage)
{
_staticCacheManager.RemoveByPrefix(PICTURE_URL_PATTERN_KEY);
}
}
}