mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Added signal to invalidate media profile cache when newly published.
This commit is contained in:
parent
0e627f8810
commit
0da9370296
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user