diff --git a/src/Umbraco.Web/Cache/DistributedCache.cs b/src/Umbraco.Web/Cache/DistributedCache.cs index 8fa1dec3b3..7b3d74d77b 100644 --- a/src/Umbraco.Web/Cache/DistributedCache.cs +++ b/src/Umbraco.Web/Cache/DistributedCache.cs @@ -59,23 +59,6 @@ namespace Umbraco.Web.Cache private static readonly DistributedCache InstanceObject = new DistributedCache(); - ///// - ///// Fired when any cache refresher method has fired - ///// - ///// - ///// This could be used by developers to know when a cache refresher has executed on the local server. - ///// Similarly to the content.AfterUpdateDocumentCache which fires locally on each machine. - ///// - //public event EventHandler CacheChanged; - - //private void OnCacheChanged(CacheUpdatedEventArgs args) - //{ - // if (CacheChanged != null) - // { - // CacheChanged(this, args); - // } - //} - /// /// Constructor /// @@ -108,6 +91,8 @@ namespace Umbraco.Web.Cache /// public void Refresh(Guid factoryGuid, Func getNumericId, params T[] instances) { + if (factoryGuid == Guid.Empty || instances.Length == 0 || getNumericId == null) return; + ServerMessengerResolver.Current.Messenger.PerformRefresh( ServerRegistrarResolver.Current.Registrar.Registrations, GetRefresherById(factoryGuid), @@ -123,6 +108,8 @@ namespace Umbraco.Web.Cache /// The id of the node. public void Refresh(Guid factoryGuid, int id) { + if (factoryGuid == Guid.Empty || id == default(int)) return; + ServerMessengerResolver.Current.Messenger.PerformRefresh( ServerRegistrarResolver.Current.Registrar.Registrations, GetRefresherById(factoryGuid), @@ -137,6 +124,8 @@ namespace Umbraco.Web.Cache /// The guid of the node. public void Refresh(Guid factoryGuid, Guid id) { + if (factoryGuid == Guid.Empty || id == Guid.Empty) return; + ServerMessengerResolver.Current.Messenger.PerformRefresh( ServerRegistrarResolver.Current.Registrar.Registrations, GetRefresherById(factoryGuid), @@ -151,6 +140,8 @@ namespace Umbraco.Web.Cache /// public void RefreshByJson(Guid factoryGuid, string jsonPayload) { + if (factoryGuid == Guid.Empty || jsonPayload.IsNullOrWhiteSpace()) return; + ServerMessengerResolver.Current.Messenger.PerformRefresh( ServerRegistrarResolver.Current.Registrar.Registrations, GetRefresherById(factoryGuid), @@ -164,6 +155,8 @@ namespace Umbraco.Web.Cache /// The unique identifier. public void RefreshAll(Guid factoryGuid) { + if (factoryGuid == Guid.Empty) return; + RefreshAll(factoryGuid, true); } @@ -177,6 +170,8 @@ namespace Umbraco.Web.Cache /// public void RefreshAll(Guid factoryGuid, bool allServers) { + if (factoryGuid == Guid.Empty) return; + ServerMessengerResolver.Current.Messenger.PerformRefreshAll( allServers ? ServerRegistrarResolver.Current.Registrar.Registrations @@ -192,6 +187,8 @@ namespace Umbraco.Web.Cache /// The id. public void Remove(Guid factoryGuid, int id) { + if (factoryGuid == Guid.Empty || id == default(int)) return; + ServerMessengerResolver.Current.Messenger.PerformRemove( ServerRegistrarResolver.Current.Registrar.Registrations, GetRefresherById(factoryGuid),