* Pass notification state to cache refreshers. Pass previous user name into member saved notification state and use when refreshing cache to clear the member by keys based on this. * Fixed issue raised in code review. * Fixed casing for state key. * Added removed parameter to unit tests. * Fix breaking change.
29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Notifications;
|
|
using Umbraco.Cms.Core.Services.Changes;
|
|
using Umbraco.Extensions;
|
|
|
|
namespace Umbraco.Cms.Core.Cache;
|
|
|
|
/// <inheritdoc />
|
|
public sealed class MediaTreeChangeDistributedCacheNotificationHandler : TreeChangeDistributedCacheNotificationHandlerBase<IMedia, MediaTreeChangeNotification>
|
|
{
|
|
private readonly DistributedCache _distributedCache;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="MediaTreeChangeDistributedCacheNotificationHandler" /> class.
|
|
/// </summary>
|
|
/// <param name="distributedCache">The distributed cache.</param>
|
|
public MediaTreeChangeDistributedCacheNotificationHandler(DistributedCache distributedCache)
|
|
=> _distributedCache = distributedCache;
|
|
|
|
/// <inheritdoc />
|
|
[Obsolete("Scheduled for removal in Umbraco 18.")]
|
|
protected override void Handle(IEnumerable<TreeChange<IMedia>> entities)
|
|
=> Handle(entities, new Dictionary<string, object?>());
|
|
|
|
/// <inheritdoc />
|
|
protected override void Handle(IEnumerable<TreeChange<IMedia>> entities, IDictionary<string, object?> state)
|
|
=> _distributedCache.RefreshMediaCache(entities);
|
|
}
|