Merge pull request #6059 from flew2bits/InvalidateNewMediaProfileCache2

[Fixes #6051] Invalidate cache when a profile is changed
This commit is contained in:
Sébastien Ros 2015-11-20 14:18:27 -08:00
commit 162ec9410c
2 changed files with 13 additions and 3 deletions

View File

@ -1,11 +1,21 @@
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

@ -31,8 +31,8 @@ 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)