Fixes small bug when distributed cache is called with invalid params.

This commit is contained in:
Shannon
2014-03-21 17:04:30 +11:00
parent 672672d0aa
commit beb1979b46

View File

@@ -59,23 +59,6 @@ namespace Umbraco.Web.Cache
private static readonly DistributedCache InstanceObject = new DistributedCache();
///// <summary>
///// Fired when any cache refresher method has fired
///// </summary>
///// <remarks>
///// 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.
///// </remarks>
//public event EventHandler<CacheUpdatedEventArgs> CacheChanged;
//private void OnCacheChanged(CacheUpdatedEventArgs args)
//{
// if (CacheChanged != null)
// {
// CacheChanged(this, args);
// }
//}
/// <summary>
/// Constructor
/// </summary>
@@ -108,6 +91,8 @@ namespace Umbraco.Web.Cache
/// </remarks>
public void Refresh<T>(Guid factoryGuid, Func<T, int> getNumericId, params T[] instances)
{
if (factoryGuid == Guid.Empty || instances.Length == 0 || getNumericId == null) return;
ServerMessengerResolver.Current.Messenger.PerformRefresh<T>(
ServerRegistrarResolver.Current.Registrar.Registrations,
GetRefresherById(factoryGuid),
@@ -123,6 +108,8 @@ namespace Umbraco.Web.Cache
/// <param name="id">The id of the node.</param>
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
/// <param name="id">The guid of the node.</param>
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
/// <param name="jsonPayload"></param>
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
/// <param name="factoryGuid">The unique identifier.</param>
public void RefreshAll(Guid factoryGuid)
{
if (factoryGuid == Guid.Empty) return;
RefreshAll(factoryGuid, true);
}
@@ -177,6 +170,8 @@ namespace Umbraco.Web.Cache
/// </param>
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
/// <param name="id">The id.</param>
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),