2017-07-20 11:21:28 +02:00
|
|
|
|
using System;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
using System.Linq;
|
2013-02-12 04:47:36 +06:00
|
|
|
|
using Umbraco.Core.Models;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
using Umbraco.Core.Services.Changes;
|
2013-02-07 04:26:48 +06:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2016-05-26 17:12:04 +02: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
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region PublicAccessCache
|
2014-03-27 14:28:45 +11:00
|
|
|
|
|
|
|
|
|
|
public static void RefreshPublicAccess(this DistributedCache dc)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshAll(PublicAccessCacheRefresher.UniqueId);
|
2014-03-27 14:28:45 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region ApplicationTreeCache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
|
public static void RefreshAllApplicationTreeCache(this DistributedCache dc)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshAll(ApplicationTreeCacheRefresher.UniqueId);
|
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
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region ApplicationCache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2013-04-04 21:57:41 +06:00
|
|
|
|
public static void RefreshAllApplicationCache(this DistributedCache dc)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshAll(ApplicationCacheRefresher.UniqueId);
|
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
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
#region User cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RemoveUserCache(this DistributedCache dc, int userId)
|
2013-04-04 03:43:05 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.Remove(UserCacheRefresher.UniqueId, userId);
|
2013-04-04 03:43:05 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshUserCache(this DistributedCache dc, int userId)
|
2013-04-04 03:43:05 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.Refresh(UserCacheRefresher.UniqueId, userId);
|
2013-04-04 03:43:05 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshAllUserCache(this DistributedCache dc)
|
2013-04-04 03:43:05 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.RefreshAll(UserCacheRefresher.UniqueId);
|
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
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
#region User group cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RemoveUserGroupCache(this DistributedCache dc, int userId)
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.Remove(UserGroupCacheRefresher.UniqueId, userId);
|
2013-02-12 04:13:29 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshUserGroupCache(this DistributedCache dc, int userId)
|
2013-02-12 04:13:29 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.Refresh(UserGroupCacheRefresher.UniqueId, userId);
|
2013-04-04 00:30:28 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshAllUserGroupCache(this DistributedCache dc)
|
2013-04-04 00:30:28 +06:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.RefreshAll(UserGroupCacheRefresher.UniqueId);
|
2016-05-26 17:12:04 +02: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
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
#region User group permissions cache
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RemoveUserGroupPermissionsCache(this DistributedCache dc, int groupId)
|
2013-07-09 11:47:46 +10:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.Remove(UserGroupPermissionsCacheRefresher.UniqueId, groupId);
|
2013-07-09 11:47:46 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshUserGroupPermissionsCache(this DistributedCache dc, int groupId)
|
2013-07-09 11:47:46 +10:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
//TODO: Not sure if we need this yet depends if we start caching permissions
|
|
|
|
|
|
//dc.Refresh(UserGroupPermissionsCacheRefresher.UniqueId, groupId);
|
2013-07-09 11:47:46 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-08 19:39:13 +02:00
|
|
|
|
public static void RefreshAllUserGroupPermissionsCache(this DistributedCache dc)
|
2013-07-09 11:47:46 +10:00
|
|
|
|
{
|
2017-09-08 19:39:13 +02:00
|
|
|
|
dc.RefreshAll(UserGroupPermissionsCacheRefresher.UniqueId);
|
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
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region TemplateCache
|
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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(TemplateCacheRefresher.UniqueId, 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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(TemplateCacheRefresher.UniqueId, templateId);
|
|
|
|
|
|
}
|
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
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region DictionaryCache
|
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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(DictionaryCacheRefresher.UniqueId, dictionaryItemId);
|
2013-03-23 01:59:25 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RemoveDictionaryCache(this DistributedCache dc, int dictionaryItemId)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(DictionaryCacheRefresher.UniqueId, dictionaryItemId);
|
2013-03-23 01:59:25 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
|
|
|
|
|
#region DataTypeCache
|
2013-05-07 19:37:57 -10:00
|
|
|
|
|
2018-01-10 12:48:51 +01:00
|
|
|
|
public static void RefreshDataTypeCache(this DistributedCache dc, IDataType dataType)
|
2013-05-07 19:37:57 -10:00
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
|
if (dataType == null) return;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = new[] { new DataTypeCacheRefresher.JsonPayload(dataType.Id, dataType.Key, false) };
|
|
|
|
|
|
dc.RefreshByPayload(DataTypeCacheRefresher.UniqueId, payloads);
|
2013-05-07 19:37:57 -10:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-10 12:48:51 +01:00
|
|
|
|
public static void RemoveDataTypeCache(this DistributedCache dc, IDataType dataType)
|
2013-03-22 05:04:32 +06:00
|
|
|
|
{
|
2015-03-04 12:16:28 +01:00
|
|
|
|
if (dataType == null) return;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = new[] { new DataTypeCacheRefresher.JsonPayload(dataType.Id, dataType.Key, true) };
|
|
|
|
|
|
dc.RefreshByPayload(DataTypeCacheRefresher.UniqueId, payloads);
|
2013-03-22 05:04:32 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region ContentCache
|
2013-02-12 04:47:36 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshAllContentCache(this DistributedCache dc)
|
2013-02-07 04:26:48 +06:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = new[] { new ContentCacheRefresher.JsonPayload(0, TreeChangeTypes.RefreshAll) };
|
2013-02-12 07:35:47 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
// note: refresh all content cache does refresh content types too
|
|
|
|
|
|
dc.RefreshByPayload(ContentCacheRefresher.UniqueId, payloads);
|
2014-03-06 17:50:08 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshContentCache(this DistributedCache dc, TreeChange<IContent>[] changes)
|
2014-03-06 17:50:08 +11:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
if (changes.Length == 0) return;
|
2014-03-06 17:50:08 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = changes
|
|
|
|
|
|
.Select(x => new ContentCacheRefresher.JsonPayload(x.Item.Id, x.ChangeTypes));
|
2014-03-06 17:50:08 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(ContentCacheRefresher.UniqueId, payloads);
|
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
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region MemberCache
|
2014-03-06 18:25:38 +11:00
|
|
|
|
|
|
|
|
|
|
public static void RefreshMemberCache(this DistributedCache dc, params IMember[] members)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(MemberCacheRefresher.UniqueId, x => x.Id, members);
|
2014-03-06 18:25:38 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RemoveMemberCache(this DistributedCache dc, params IMember[] members)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(MemberCacheRefresher.UniqueId, 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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(MemberCacheRefresher.UniqueId, 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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(MemberCacheRefresher.UniqueId, memberId);
|
|
|
|
|
|
}
|
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
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region MemberGroupCache
|
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)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(MemberGroupCacheRefresher.UniqueId, memberGroupId);
|
2014-02-12 17:14:16 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RemoveMemberGroupCache(this DistributedCache dc, int memberGroupId)
|
|
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(MemberGroupCacheRefresher.UniqueId, 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
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region MediaCache
|
2013-02-12 07:35:47 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshAllMediaCache(this DistributedCache dc)
|
2014-04-23 20:19:36 +10:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = new[] { new MediaCacheRefresher.JsonPayload(0, TreeChangeTypes.RefreshAll) };
|
2015-03-04 12:16:28 +01:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
// note: refresh all media cache does refresh content types too
|
|
|
|
|
|
dc.RefreshByPayload(MediaCacheRefresher.UniqueId, payloads);
|
2013-02-07 05:53:59 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshMediaCache(this DistributedCache dc, TreeChange<IMedia>[] changes)
|
2013-02-12 07:35:47 +06:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
if (changes.Length == 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
var payloads = changes
|
|
|
|
|
|
.Select(x => new MediaCacheRefresher.JsonPayload(x.Item.Id, x.ChangeTypes));
|
|
|
|
|
|
|
|
|
|
|
|
dc.RefreshByPayload(MediaCacheRefresher.UniqueId, payloads);
|
2014-04-23 20:19:36 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2017-10-31 12:48:24 +01:00
|
|
|
|
#region Published Snapshot
|
2016-05-26 17:12:04 +02:00
|
|
|
|
|
2017-10-31 12:48:24 +01:00
|
|
|
|
public static void RefreshAllPublishedSnapshot(this DistributedCache dc)
|
2014-04-23 20:19:36 +10:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
// note: refresh all content & media caches does refresh content types too
|
|
|
|
|
|
dc.RefreshAllContentCache();
|
|
|
|
|
|
dc.RefreshAllMediaCache();
|
|
|
|
|
|
dc.RefreshAllDomainCache();
|
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
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region MacroCache
|
2013-02-12 07:35:47 +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;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByJson(MacroCacheRefresher.UniqueId, MacroCacheRefresher.Serialize(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;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByJson(MacroCacheRefresher.UniqueId, MacroCacheRefresher.Serialize(macro));
|
2013-10-31 17:22:10 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 08:38:18 +06:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
#region Content/Media/Member type cache
|
2013-03-16 08:47:55 +06:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshContentTypeCache(this DistributedCache dc, ContentTypeChange<IContentType>[] changes)
|
2014-01-23 13:33:58 +11:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
if (changes.Length == 0) return;
|
2014-01-23 13:33:58 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = changes
|
|
|
|
|
|
.Select(x => new ContentTypeCacheRefresher.JsonPayload(typeof (IContentType).Name, x.Item.Id, x.ChangeTypes));
|
2014-01-23 13:33:58 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(ContentTypeCacheRefresher.UniqueId, payloads);
|
2013-03-16 08:47:55 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshContentTypeCache(this DistributedCache dc, ContentTypeChange<IMediaType>[] changes)
|
2013-03-12 22:58:21 +04:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
if (changes.Length == 0) return;
|
2014-01-23 13:33:58 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
var payloads = changes
|
|
|
|
|
|
.Select(x => new ContentTypeCacheRefresher.JsonPayload(typeof(IMediaType).Name, x.Item.Id, x.ChangeTypes));
|
2014-01-23 13:33:58 +11:00
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(ContentTypeCacheRefresher.UniqueId, payloads);
|
2014-01-23 13:33:58 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-26 17:12:04 +02:00
|
|
|
|
public static void RefreshContentTypeCache(this DistributedCache dc, ContentTypeChange<IMemberType>[] changes)
|
2014-01-23 13:33:58 +11:00
|
|
|
|
{
|
2016-05-26 17:12:04 +02:00
|
|
|
|
if (changes.Length == 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
var payloads = changes
|
|
|
|
|
|
.Select(x => new ContentTypeCacheRefresher.JsonPayload(typeof(IMemberType).Name, x.Item.Id, x.ChangeTypes));
|
|
|
|
|
|
|
|
|
|
|
|
dc.RefreshByPayload(ContentTypeCacheRefresher.UniqueId, payloads);
|
2014-01-23 13:33:58 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-21 08:38:18 +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;
|
2016-06-08 14:19:15 +02:00
|
|
|
|
var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainChangeTypes.Refresh) };
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads);
|
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;
|
2016-06-08 14:19:15 +02:00
|
|
|
|
var payloads = new[] { new DomainCacheRefresher.JsonPayload(domain.Id, DomainChangeTypes.Remove) };
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RefreshAllDomainCache(this DistributedCache dc)
|
|
|
|
|
|
{
|
2016-06-08 14:19:15 +02:00
|
|
|
|
var payloads = new[] { new DomainCacheRefresher.JsonPayload(0, DomainChangeTypes.RefreshAll) };
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.RefreshByPayload(DomainCacheRefresher.UniqueId, payloads);
|
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;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Refresh(LanguageCacheRefresher.UniqueId, 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;
|
2016-05-26 17:12:04 +02:00
|
|
|
|
dc.Remove(LanguageCacheRefresher.UniqueId, language.Id);
|
2013-03-22 00:35:15 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2016-11-09 13:05:23 +01:00
|
|
|
|
|
|
|
|
|
|
#region Relation type cache
|
|
|
|
|
|
|
|
|
|
|
|
public static void RefreshRelationTypeCache(this DistributedCache dc, int id)
|
|
|
|
|
|
{
|
2016-11-23 10:33:12 +01:00
|
|
|
|
dc.Refresh(RelationTypeCacheRefresher.UniqueId, id);
|
2016-11-09 13:05:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void RemoveRelationTypeCache(this DistributedCache dc, int id)
|
|
|
|
|
|
{
|
2016-11-23 10:33:12 +01:00
|
|
|
|
dc.Remove(RelationTypeCacheRefresher.UniqueId, id);
|
2016-11-09 13:05:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2013-02-07 04:26:48 +06:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|