Merge pull request #1614 from umbraco/temp-u4-9077
U4-9077 - relation type repository cache
This commit is contained in:
@@ -125,9 +125,12 @@ namespace Umbraco.Web.Cache
|
||||
|
||||
//public access events
|
||||
PublicAccessService.Saved += PublicAccessService_Saved;
|
||||
PublicAccessService.Deleted += PublicAccessService_Deleted; ;
|
||||
PublicAccessService.Deleted += PublicAccessService_Deleted;
|
||||
|
||||
RelationService.SavedRelationType += RelationType_Saved;
|
||||
RelationService.DeletedRelationType += RelationType_Deleted;
|
||||
}
|
||||
|
||||
|
||||
#region Publishing
|
||||
|
||||
void PublishingStrategy_UnPublished(IPublishingStrategy sender, PublishEventArgs<IContent> e)
|
||||
@@ -661,7 +664,25 @@ namespace Umbraco.Web.Cache
|
||||
{
|
||||
DistributedCache.Instance.RemoveMemberGroupCache(m.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Relation type event handlers
|
||||
|
||||
private static void RelationType_Saved(IRelationService sender, SaveEventArgs<IRelationType> args)
|
||||
{
|
||||
var dc = DistributedCache.Instance;
|
||||
foreach (var e in args.SavedEntities)
|
||||
dc.RefreshRelationTypeCache(e.Id);
|
||||
}
|
||||
|
||||
private static void RelationType_Deleted(IRelationService sender, DeleteEventArgs<IRelationType> args)
|
||||
{
|
||||
var dc = DistributedCache.Instance;
|
||||
foreach (var e in args.DeletedEntities)
|
||||
dc.RemoveRelationTypeCache(e.Id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ namespace Umbraco.Web.Cache
|
||||
public const string ContentTypeCacheRefresherId = "6902E22C-9C10-483C-91F3-66B7CAE9E2F5";
|
||||
public const string LanguageCacheRefresherId = "3E0F95D8-0BE5-44B8-8394-2B8750B62654";
|
||||
public const string DomainCacheRefresherId = "11290A79-4B57-4C99-AD72-7748A3CF38AF";
|
||||
public const string RelationTypeCacheRefresherId = "D8375ABA-4FB3-4F86-B505-92FBA1B6F7C9";
|
||||
|
||||
[Obsolete("This is no longer used and will be removed in future versions")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
@@ -67,6 +68,7 @@ namespace Umbraco.Web.Cache
|
||||
public static readonly Guid DataTypeCacheRefresherGuid = new Guid(DataTypeCacheRefresherId);
|
||||
public static readonly Guid DictionaryCacheRefresherGuid = new Guid(DictionaryCacheRefresherId);
|
||||
public static readonly Guid PublicAccessCacheRefresherGuid = new Guid(PublicAccessCacheRefresherId);
|
||||
public static readonly Guid RelationTypeCacheRefresherGuid = new Guid(RelationTypeCacheRefresherId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -446,5 +446,19 @@ namespace Umbraco.Web.Cache
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Relation type cache
|
||||
|
||||
public static void RefreshRelationTypeCache(this DistributedCache dc, int id)
|
||||
{
|
||||
dc.Refresh(DistributedCache.RelationTypeCacheRefresherGuid, id);
|
||||
}
|
||||
|
||||
public static void RemoveRelationTypeCache(this DistributedCache dc, int id)
|
||||
{
|
||||
dc.Remove(DistributedCache.RelationTypeCacheRefresherGuid, id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
52
src/Umbraco.Web/Cache/RelationTypeCacheRefresher.cs
Normal file
52
src/Umbraco.Web/Cache/RelationTypeCacheRefresher.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
|
||||
namespace Umbraco.Web.Cache
|
||||
{
|
||||
public sealed class RelationTypeCacheRefresher : CacheRefresherBase<RelationTypeCacheRefresher>
|
||||
{
|
||||
protected override RelationTypeCacheRefresher Instance
|
||||
{
|
||||
get { return this; }
|
||||
}
|
||||
|
||||
public override Guid UniqueIdentifier
|
||||
{
|
||||
get { return DistributedCache.RelationTypeCacheRefresherGuid; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Relation Type Cache Refresher"; }
|
||||
}
|
||||
|
||||
public override void RefreshAll()
|
||||
{
|
||||
ClearAllIsolatedCacheByEntityType<IRelationType>();
|
||||
base.RefreshAll();
|
||||
}
|
||||
|
||||
public override void Refresh(int id)
|
||||
{
|
||||
var cache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IRelationType>();
|
||||
if (cache) cache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IRelationType>(id));
|
||||
base.Refresh(id);
|
||||
}
|
||||
|
||||
public override void Refresh(Guid id)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
//base.Refresh(id);
|
||||
}
|
||||
|
||||
public override void Remove(int id)
|
||||
{
|
||||
var cache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IRelationType>();
|
||||
if (cache) cache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IRelationType>(id));
|
||||
base.Remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user