2013-02-07 04:26:48 +06:00
|
|
|
using System;
|
2013-03-16 01:37:05 +06:00
|
|
|
using Umbraco.Core;
|
2013-09-16 11:22:11 +10:00
|
|
|
using Umbraco.Core.Configuration;
|
2014-04-23 20:19:36 +10:00
|
|
|
using Umbraco.Core.Events;
|
2013-02-12 04:47:36 +06:00
|
|
|
using Umbraco.Core.Models;
|
2013-03-12 03:00:42 +04:00
|
|
|
using umbraco;
|
2013-03-22 00:49:07 +06:00
|
|
|
using umbraco.cms.businesslogic.web;
|
2013-02-07 04:26:48 +06:00
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2015-03-04 12:16:28 +01:00
|
|
|
/// Extension methods for <see cref="DistributedCache"/>
|
2013-02-07 04:26:48 +06:00
|
|
|
/// </summary>
|
2013-03-23 01:59:25 +06:00
|
|
|
internal static class DistributedCacheExtensions
|
2013-02-07 04:26:48 +06:00
|
|
|
{
|
2014-03-27 14:28:45 +11:00
|
|
|
#region Public access
|
|
|
|
|
|
|
|
|
|
public static void RefreshPublicAccess(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.PublicAccessCacheRefresherGuid);
|
2014-03-27 14:28:45 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
#region Application tree cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
public static void RefreshAllApplicationTreeCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.ApplicationTreeCacheRefresherGuid);
|
2013-04-04 21:57:41 +06:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Application cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
public static void RefreshAllApplicationCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.ApplicationCacheRefresherGuid);
|
2013-04-04 21:57:41 +06:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
#endregion
|
|
|
|
|
|
2013-04-04 03:43:05 +06:00
|
|
|
#region User type cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 03:43:05 +06:00
|
|
|
public static void RemoveUserTypeCache(this DistributedCache dc, int userTypeId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.UserTypeCacheRefresherGuid, userTypeId);
|
2013-04-04 03:43:05 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshUserTypeCache(this DistributedCache dc, int userTypeId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.UserTypeCacheRefresherGuid, userTypeId);
|
2013-04-04 03:43:05 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshAllUserTypeCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.UserTypeCacheRefresherGuid);
|
2013-04-04 03:43:05 +06:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-04-04 03:43:05 +06:00
|
|
|
#endregion
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#region User cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-02-12 04:13:29 +06:00
|
|
|
public static void RemoveUserCache(this DistributedCache dc, int userId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.UserCacheRefresherGuid, userId);
|
2013-02-12 04:13:29 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshUserCache(this DistributedCache dc, int userId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.UserCacheRefresherGuid, userId);
|
2013-04-04 00:30:28 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshAllUserCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.UserCacheRefresherGuid);
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
2013-02-12 04:13:29 +06:00
|
|
|
|
2013-07-09 11:47:46 +10:00
|
|
|
#region User permissions cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-07-09 11:47:46 +10:00
|
|
|
public static void RemoveUserPermissionsCache(this DistributedCache dc, int userId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.UserPermissionsCacheRefresherGuid, userId);
|
2013-07-09 11:47:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshUserPermissionsCache(this DistributedCache dc, int userId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.UserPermissionsCacheRefresherGuid, userId);
|
2013-07-09 11:47:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshAllUserPermissionsCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.UserPermissionsCacheRefresherGuid);
|
2013-07-09 11:47:46 +10:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-07-09 11:47:46 +10:00
|
|
|
#endregion
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#region Template cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-02-07 04:26:48 +06:00
|
|
|
public static void RefreshTemplateCache(this DistributedCache dc, int templateId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.TemplateRefresherGuid, templateId);
|
2013-02-07 04:26:48 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-07 05:26:53 +06:00
|
|
|
public static void RemoveTemplateCache(this DistributedCache dc, int templateId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.TemplateRefresherGuid, templateId);
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2013-03-22 02:08:55 +06:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
2013-02-07 05:26:53 +06:00
|
|
|
|
2013-03-23 01:59:25 +06:00
|
|
|
#region Dictionary cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-03-23 01:59:25 +06:00
|
|
|
public static void RefreshDictionaryCache(this DistributedCache dc, int dictionaryItemId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.DictionaryCacheRefresherGuid, dictionaryItemId);
|
2013-03-23 01:59:25 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveDictionaryCache(this DistributedCache dc, int dictionaryItemId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.DictionaryCacheRefresherGuid, dictionaryItemId);
|
2013-03-23 01:59:25 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-03-06 17:50:08 +11:00
|
|
|
|
2013-03-22 05:04:32 +06:00
|
|
|
#region Data type cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-05-07 19:37:57 -10:00
|
|
|
public static void RefreshDataTypeCache(this DistributedCache dc, global::umbraco.cms.businesslogic.datatype.DataTypeDefinition dataType)
|
2013-03-22 05:04:32 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (dataType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.DataTypeCacheRefresherGuid, DataTypeCacheRefresher.SerializeToJsonPayload(dataType));
|
2013-03-22 05:04:32 +06:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 19:37:57 -10:00
|
|
|
public static void RemoveDataTypeCache(this DistributedCache dc, global::umbraco.cms.businesslogic.datatype.DataTypeDefinition dataType)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (dataType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.DataTypeCacheRefresherGuid, DataTypeCacheRefresher.SerializeToJsonPayload(dataType));
|
2013-05-07 19:37:57 -10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshDataTypeCache(this DistributedCache dc, IDataTypeDefinition dataType)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (dataType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.DataTypeCacheRefresherGuid, DataTypeCacheRefresher.SerializeToJsonPayload(dataType));
|
2013-05-07 19:37:57 -10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveDataTypeCache(this DistributedCache dc, IDataTypeDefinition dataType)
|
2013-03-22 05:04:32 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (dataType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.DataTypeCacheRefresherGuid, DataTypeCacheRefresher.SerializeToJsonPayload(dataType));
|
2013-03-22 05:04:32 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#region Page cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-02-07 04:26:48 +06:00
|
|
|
public static void RefreshAllPageCache(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshAll(DistributedCache.PageCacheRefresherGuid);
|
2013-02-07 04:26:48 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-12 07:35:47 +06:00
|
|
|
public static void RefreshPageCache(this DistributedCache dc, int documentId)
|
2013-02-07 04:26:48 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.PageCacheRefresherGuid, documentId);
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2013-02-07 04:26:48 +06:00
|
|
|
|
2013-02-12 07:35:47 +06:00
|
|
|
public static void RefreshPageCache(this DistributedCache dc, params IContent[] content)
|
2013-02-12 04:47:36 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.PageCacheRefresherGuid, x => x.Id, content);
|
2013-02-12 04:47:36 +06:00
|
|
|
}
|
|
|
|
|
|
2013-02-12 07:35:47 +06:00
|
|
|
public static void RemovePageCache(this DistributedCache dc, params IContent[] content)
|
2013-02-07 04:26:48 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.PageCacheRefresherGuid, x => x.Id, content);
|
2013-02-12 07:35:47 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemovePageCache(this DistributedCache dc, int documentId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.PageCacheRefresherGuid, documentId);
|
2014-03-06 17:50:08 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshUnpublishedPageCache(this DistributedCache dc, params IContent[] content)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.UnpublishedPageCacheRefresherGuid, x => x.Id, content);
|
2014-03-06 17:50:08 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveUnpublishedPageCache(this DistributedCache dc, params IContent[] content)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.UnpublishedPageCacheRefresherGuid, x => x.Id, content);
|
2014-03-06 17:50:08 +11:00
|
|
|
}
|
|
|
|
|
|
2014-04-23 20:19:36 +10:00
|
|
|
public static void RemoveUnpublishedCachePermanently(this DistributedCache dc, params int[] contentIds)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshByJson(DistributedCache.UnpublishedPageCacheRefresherGuid, UnpublishedPageCacheRefresher.SerializeToJsonPayloadForPermanentDeletion(contentIds));
|
2014-04-23 20:19:36 +10:00
|
|
|
}
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
2013-02-07 04:26:48 +06:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#region Member cache
|
2014-03-06 18:25:38 +11:00
|
|
|
|
|
|
|
|
public static void RefreshMemberCache(this DistributedCache dc, params IMember[] members)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.MemberCacheRefresherGuid, x => x.Id, members);
|
2014-03-06 18:25:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveMemberCache(this DistributedCache dc, params IMember[] members)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.MemberCacheRefresherGuid, x => x.Id, members);
|
2014-03-06 18:25:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Obsolete("Use the RefreshMemberCache with strongly typed IMember objects instead")]
|
2013-02-07 04:26:48 +06:00
|
|
|
public static void RefreshMemberCache(this DistributedCache dc, int memberId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.MemberCacheRefresherGuid, memberId);
|
2013-02-07 04:26:48 +06:00
|
|
|
}
|
|
|
|
|
|
2014-03-06 18:25:38 +11:00
|
|
|
[Obsolete("Use the RemoveMemberCache with strongly typed IMember objects instead")]
|
2013-02-07 05:53:59 +06:00
|
|
|
public static void RemoveMemberCache(this DistributedCache dc, int memberId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.MemberCacheRefresherGuid, memberId);
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2014-01-23 14:55:41 +11:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
2013-02-07 05:53:59 +06:00
|
|
|
|
2014-02-12 17:14:16 +11:00
|
|
|
#region Member group cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2014-02-12 17:14:16 +11:00
|
|
|
public static void RefreshMemberGroupCache(this DistributedCache dc, int memberGroupId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Refresh(DistributedCache.MemberGroupCacheRefresherGuid, memberGroupId);
|
2014-02-12 17:14:16 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveMemberGroupCache(this DistributedCache dc, int memberGroupId)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.Remove(DistributedCache.MemberGroupCacheRefresherGuid, memberGroupId);
|
2014-02-12 17:14:16 +11:00
|
|
|
}
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
2013-02-07 05:53:59 +06:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#region Media Cache
|
2013-03-21 22:53:58 +06:00
|
|
|
|
2013-02-12 07:35:47 +06:00
|
|
|
public static void RefreshMediaCache(this DistributedCache dc, params IMedia[] media)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayload(MediaCacheRefresher.OperationType.Saved, media));
|
2013-02-12 07:35:47 +06:00
|
|
|
}
|
|
|
|
|
|
2014-04-23 20:19:36 +10:00
|
|
|
public static void RefreshMediaCacheAfterMoving(this DistributedCache dc, params MoveEventInfo<IMedia>[] media)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayloadForMoving(MediaCacheRefresher.OperationType.Saved, media));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clearing by Id will never work for load balanced scenarios for media since we require a Path
|
|
|
|
|
// to clear all of the cache but the media item will be removed before the other servers can
|
|
|
|
|
// look it up. Only here for legacy purposes.
|
2014-03-06 17:50:08 +11:00
|
|
|
[Obsolete("Ensure to clear with other RemoveMediaCache overload")]
|
2013-02-07 05:53:59 +06:00
|
|
|
public static void RemoveMediaCache(this DistributedCache dc, int mediaId)
|
|
|
|
|
{
|
|
|
|
|
dc.Remove(new Guid(DistributedCache.MediaCacheRefresherId), mediaId);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 20:19:36 +10:00
|
|
|
public static void RemoveMediaCacheAfterRecycling(this DistributedCache dc, params MoveEventInfo<IMedia>[] media)
|
2013-02-12 07:35:47 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayloadForMoving(MediaCacheRefresher.OperationType.Trashed, media));
|
2014-04-23 20:19:36 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveMediaCachePermanently(this DistributedCache dc, params int[] mediaIds)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
dc.RefreshByJson(DistributedCache.MediaCacheRefresherGuid, MediaCacheRefresher.SerializeToJsonPayloadForPermanentDeletion(mediaIds));
|
2014-04-23 20:19:36 +10:00
|
|
|
}
|
2013-03-21 22:53:58 +06:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Macro Cache
|
2013-02-12 07:35:47 +06:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
public static void ClearAllMacroCacheOnCurrentServer(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
// NOTE: The 'false' ensure that it will only refresh on the current server, not post to all servers
|
|
|
|
|
dc.RefreshAll(DistributedCache.MacroCacheRefresherGuid, false);
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2013-10-31 17:22:10 +11:00
|
|
|
|
|
|
|
|
public static void RefreshMacroCache(this DistributedCache dc, IMacro macro)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (macro == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
|
2013-10-31 17:22:10 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveMacroCache(this DistributedCache dc, IMacro macro)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (macro == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
|
2013-10-31 17:22:10 +11:00
|
|
|
}
|
|
|
|
|
|
2013-03-12 03:00:42 +04:00
|
|
|
public static void RefreshMacroCache(this DistributedCache dc, global::umbraco.cms.businesslogic.macro.Macro macro)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (macro == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
|
2013-03-12 03:00:42 +04:00
|
|
|
}
|
2013-03-21 22:53:58 +06:00
|
|
|
|
2013-03-12 03:00:42 +04:00
|
|
|
public static void RemoveMacroCache(this DistributedCache dc, global::umbraco.cms.businesslogic.macro.Macro macro)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (macro == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
|
2013-03-12 03:00:42 +04:00
|
|
|
}
|
2013-03-12 17:08:31 +04:00
|
|
|
|
|
|
|
|
public static void RemoveMacroCache(this DistributedCache dc, macro macro)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (macro == null || macro.Model == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
|
2013-03-21 08:38:18 +06:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
|
|
|
|
|
2014-01-23 13:33:58 +11:00
|
|
|
#region Document type cache
|
2013-03-12 22:58:21 +04:00
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
public static void RefreshContentTypeCache(this DistributedCache dc, IContentType contentType)
|
2013-03-16 08:47:55 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (contentType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(false, contentType));
|
2013-03-16 08:47:55 +06:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 13:33:58 +11:00
|
|
|
public static void RemoveContentTypeCache(this DistributedCache dc, IContentType contentType)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (contentType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(true, contentType));
|
2014-01-23 13:33:58 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Media type cache
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
public static void RefreshMediaTypeCache(this DistributedCache dc, IMediaType mediaType)
|
2013-03-16 08:47:55 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (mediaType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(false, mediaType));
|
2013-03-16 08:47:55 +06:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 13:33:58 +11:00
|
|
|
public static void RemoveMediaTypeCache(this DistributedCache dc, IMediaType mediaType)
|
2013-03-12 22:58:21 +04:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (mediaType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(true, mediaType));
|
2013-03-16 01:37:05 +06:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 13:33:58 +11:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Media type cache
|
|
|
|
|
|
|
|
|
|
public static void RefreshMemberTypeCache(this DistributedCache dc, IMemberType memberType)
|
2013-03-21 08:38:18 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (memberType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(false, memberType));
|
2014-01-23 13:33:58 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveMemberTypeCache(this DistributedCache dc, IMemberType memberType)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (memberType == null) return;
|
|
|
|
|
dc.RefreshByJson(DistributedCache.ContentTypeCacheRefresherGuid, ContentTypeCacheRefresher.SerializeToJsonPayload(true, memberType));
|
2014-01-23 13:33:58 +11:00
|
|
|
}
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
#endregion
|
|
|
|
|
|
2013-03-22 01:49:34 +06:00
|
|
|
#region Stylesheet Cache
|
|
|
|
|
|
|
|
|
|
public static void RefreshStylesheetPropertyCache(this DistributedCache dc, global::umbraco.cms.businesslogic.web.StylesheetProperty styleSheetProperty)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheetProperty == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.StylesheetPropertyCacheRefresherGuid, styleSheetProperty.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveStylesheetPropertyCache(this DistributedCache dc, global::umbraco.cms.businesslogic.web.StylesheetProperty styleSheetProperty)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheetProperty == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.StylesheetPropertyCacheRefresherGuid, styleSheetProperty.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshStylesheetCache(this DistributedCache dc, StyleSheet styleSheet)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheet == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.StylesheetCacheRefresherGuid, styleSheet.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveStylesheetCache(this DistributedCache dc, StyleSheet styleSheet)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheet == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.StylesheetCacheRefresherGuid, styleSheet.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshStylesheetCache(this DistributedCache dc, Umbraco.Core.Models.Stylesheet styleSheet)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheet == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.StylesheetCacheRefresherGuid, styleSheet.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveStylesheetCache(this DistributedCache dc, Umbraco.Core.Models.Stylesheet styleSheet)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (styleSheet == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.StylesheetCacheRefresherGuid, styleSheet.Id);
|
2013-03-22 01:49:34 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-22 00:49:07 +06:00
|
|
|
#region Domain Cache
|
|
|
|
|
|
2015-01-22 12:17:36 +11:00
|
|
|
public static void RefreshDomainCache(this DistributedCache dc, IDomain domain)
|
2013-03-22 00:49:07 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (domain == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.DomainCacheRefresherGuid, domain.Id);
|
2013-03-22 00:49:07 +06:00
|
|
|
}
|
|
|
|
|
|
2015-01-22 12:17:36 +11:00
|
|
|
public static void RemoveDomainCache(this DistributedCache dc, IDomain domain)
|
2013-03-22 00:49:07 +06:00
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (domain == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.DomainCacheRefresherGuid, domain.Id);
|
2013-03-22 00:49:07 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-22 00:35:15 +06:00
|
|
|
#region Language Cache
|
|
|
|
|
|
|
|
|
|
public static void RefreshLanguageCache(this DistributedCache dc, ILanguage language)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (language == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.LanguageCacheRefresherGuid, language.Id);
|
2013-03-22 00:35:15 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveLanguageCache(this DistributedCache dc, ILanguage language)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (language == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.LanguageCacheRefresherGuid, language.Id);
|
2013-03-22 00:35:15 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RefreshLanguageCache(this DistributedCache dc, global::umbraco.cms.businesslogic.language.Language language)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (language == null) return;
|
|
|
|
|
dc.Refresh(DistributedCache.LanguageCacheRefresherGuid, language.id);
|
2013-03-22 00:35:15 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RemoveLanguageCache(this DistributedCache dc, global::umbraco.cms.businesslogic.language.Language language)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (language == null) return;
|
|
|
|
|
dc.Remove(DistributedCache.LanguageCacheRefresherGuid, language.id);
|
2013-03-22 00:35:15 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2015-03-04 12:16:28 +01:00
|
|
|
#region Xslt Cache
|
|
|
|
|
|
2013-03-16 01:37:05 +06:00
|
|
|
public static void ClearXsltCacheOnCurrentServer(this DistributedCache dc)
|
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
if (UmbracoConfig.For.UmbracoSettings().Content.UmbracoLibraryCacheDuration <= 0) return;
|
|
|
|
|
ApplicationContext.Current.ApplicationCache.ClearCacheObjectTypes("MS.Internal.Xml.XPath.XPathSelectionIterator");
|
2013-03-12 22:58:21 +04:00
|
|
|
}
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
|
|
|
#endregion
|
2013-02-07 04:26:48 +06:00
|
|
|
}
|
|
|
|
|
}
|