mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Merge pull request #6059 from flew2bits/InvalidateNewMediaProfileCache2
[Fixes #6051] Invalidate cache when a profile is changed
This commit is contained in:
commit
162ec9410c
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user