From f5a1e415692cd4fa5db4d9f04650efb8c1fc11e3 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 21 Mar 2013 20:30:32 +0600 Subject: [PATCH] missing checkin file --- src/Umbraco.Web/Cache/DistributedCache.cs | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/Umbraco.Web/Cache/DistributedCache.cs b/src/Umbraco.Web/Cache/DistributedCache.cs index 53647c4b27..d919510b9f 100644 --- a/src/Umbraco.Web/Cache/DistributedCache.cs +++ b/src/Umbraco.Web/Cache/DistributedCache.cs @@ -16,6 +16,11 @@ using umbraco.interfaces; namespace Umbraco.Web.Cache { + //public class CacheUpdatedEventArgs : EventArgs + //{ + + //} + /// /// DistributedCache is used to invalidate cache throughout the application which also takes in to account load balancing environments automatically /// @@ -42,6 +47,23 @@ 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 /// @@ -109,6 +131,20 @@ namespace Umbraco.Web.Cache id); } + /// + /// Sends a request to all registered load-balanced servers to refresh data based on the custom json payload + /// using the specified ICacheRefresher with the guid factoryGuid. + /// + /// + /// + public void RefreshByJson(Guid factoryGuid, string jsonPayload) + { + ServerMessengerResolver.Current.Messenger.PerformRefresh( + ServerRegistrarResolver.Current.Registrar.Registrations, + GetRefresherById(factoryGuid), + jsonPayload); + } + /// /// Sends a request to all registered load-balanced servers to refresh all nodes /// using the specified ICacheRefresher with the guid factoryGuid. @@ -167,6 +203,20 @@ namespace Umbraco.Web.Cache instances); } + /// + /// Sends a request to all registered load-balanced servers to remove data based on the custom json payload + /// using the specified ICacheRefresher with the guid factoryGuid. + /// + /// + /// + public void RemoveByJson(Guid factoryGuid, string jsonPayload) + { + ServerMessengerResolver.Current.Messenger.PerformRemove( + ServerRegistrarResolver.Current.Registrar.Registrations, + GetRefresherById(factoryGuid), + jsonPayload); + } + private static ICacheRefresher GetRefresherById(Guid uniqueIdentifier) { return CacheRefreshersResolver.Current.GetById(uniqueIdentifier);