#19873: Invalidating Media Profiles cache

Work Item: 19873
This commit is contained in:
Sebastien Ros
2013-11-01 12:16:19 -07:00
parent 89aa73d571
commit 2d4182bc85
3 changed files with 10 additions and 3 deletions

View File

@@ -65,6 +65,8 @@ namespace Orchard.MediaProcessing.Controllers {
filter.ImageProfilePartRecord.Filters.Remove(filter);
_filterRepository.Delete(filter);
_signals.Trigger("MediaProcessing_Saved_" + filter.ImageProfilePartRecord.Name);
Services.Notifier.Information(T("Filter deleted"));
return RedirectToAction("Edit", "Admin", new {id});
@@ -134,7 +136,7 @@ namespace Orchard.MediaProcessing.Controllers {
// set profile as updated
profile.ModifiedUtc = DateTime.UtcNow;
profile.FileNames.Clear();
_signals.Trigger("MediaProcessing_" + profile.Name + "_Saved");
_signals.Trigger("MediaProcessing_Saved_" + profile.Name);
return RedirectToAction("Edit", "Admin", new {id});
}

View File

@@ -59,7 +59,7 @@ namespace Orchard.MediaProcessing.Services {
private IDictionary<string, string> GetProfileCache(string profile) {
return _cacheManager.Get("MediaProcessing_" + profile, ctx => {
ctx.Monitor(_signals.When("MediaProcessing_" + profile + "_Saved"));
ctx.Monitor(_signals.When("MediaProcessing_Saved_" + profile));
var dictionary = new Dictionary<string, string>();
var profilePart = _imageProfileService.GetImageProfileByName(profile);

View File

@@ -11,14 +11,17 @@ namespace Orchard.MediaProcessing.Services {
private readonly IContentManager _contentManager;
private readonly ICacheManager _cacheManager;
private readonly IRepository<FilterRecord> _filterRepository;
private readonly ISignals _signals;
public ImageProfileService(
IContentManager contentManager,
ICacheManager cacheManager,
IRepository<FilterRecord> filterRepository) {
IRepository<FilterRecord> filterRepository,
ISignals signals) {
_contentManager = contentManager;
_cacheManager = cacheManager;
_filterRepository = filterRepository;
_signals = signals;
}
public Localizer T { get; set; }
@@ -80,6 +83,8 @@ namespace Orchard.MediaProcessing.Services {
.OrderByDescending(x => x.Position)
.FirstOrDefault();
_signals.Trigger("MediaProcessing_Saved_" + filter.ImageProfilePartRecord.Name);
// nothing to do if already at the top
if (previous == null) {
return;