Converts the media cache refresher to be a json cache refresher since it was impossible before to have media cache
cleared when media was deleted. Created base classes for cache refreshers, we now have a new event - CacheUpdated which can now be used by code to execute on each individual server when any cache refresher is updated. Listening to events normally only fire on the individual server so if people are wanting to refresh their own cache there was previously no way to do that.
This commit is contained in:
25
src/Umbraco.Core/Cache/JsonCacheRefresherBase.cs
Normal file
25
src/Umbraco.Core/Cache/JsonCacheRefresherBase.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Umbraco.Core.Sync;
|
||||
using umbraco.interfaces;
|
||||
|
||||
namespace Umbraco.Core.Cache
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class for json cache refreshers that ensures the correct events are raised when
|
||||
/// cache refreshing occurs.
|
||||
/// </summary>
|
||||
/// <typeparam name="TInstanceType">The real cache refresher type, this is used for raising strongly typed events</typeparam>
|
||||
public abstract class JsonCacheRefresherBase<TInstanceType> : CacheRefresherBase<TInstanceType>, IJsonCacheRefresher
|
||||
where TInstanceType : ICacheRefresher
|
||||
{
|
||||
|
||||
public virtual void Refresh(string jsonPayload)
|
||||
{
|
||||
OnCacheUpdated(Instance, new CacheRefresherEventArgs(jsonPayload, MessageType.RefreshByJson));
|
||||
}
|
||||
|
||||
public virtual void Remove(string jsonPayload)
|
||||
{
|
||||
OnCacheUpdated(Instance, new CacheRefresherEventArgs(jsonPayload, MessageType.RemoveByJson));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user