Added signal to invalidate media profile cache when newly published.

This commit is contained in:
flew2bits 2015-11-20 15:20:03 -05:00
parent 0e627f8810
commit 0da9370296
2 changed files with 15 additions and 2 deletions

View File

@ -1,11 +1,23 @@
using Orchard.ContentManagement.Handlers;
using Orchard.Caching;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.MediaProcessing.Models;
namespace Orchard.MediaProcessing.Handlers {
public class ImageProfilePartHandler : ContentHandler {
public ImageProfilePartHandler(IRepository<ImageProfilePartRecord> repository) {
private readonly ISignals _signals;
public ImageProfilePartHandler(IRepository<ImageProfilePartRecord> repository, ISignals signals)
{
_signals = signals;
Filters.Add(StorageFilter.For(repository));
}
protected override void Published(PublishContentContext context)
{
_signals.Trigger("MediaProcessing_Published_" + context.ContentItem.As<ImageProfilePart>().Name);
base.Published(context);
}
}
}

View File

@ -33,6 +33,7 @@ namespace Orchard.MediaProcessing.Services {
public ImageProfilePart GetImageProfileByName(string name) {
var profileId = _cacheManager.Get("ProfileId_" + name, true, ctx => {
ctx.Monitor(_signals.When("MediaProcessing_Published_" + name));
var profile = _contentManager.Query<ImageProfilePart, ImageProfilePartRecord>()
.Where(x => x.Name == name)
.Slice(0, 1)