Updates all cache refreshers to use ctor injection, no more applicationcontext singleton usages

This commit is contained in:
Shannon
2016-05-18 18:44:08 +02:00
parent 2880190b6f
commit 7fb1b4fb3b
26 changed files with 152 additions and 117 deletions

View File

@@ -13,6 +13,11 @@ namespace Umbraco.Core.Cache
public abstract class CacheRefresherBase<TInstanceType> : ICacheRefresher
where TInstanceType : ICacheRefresher
{
protected CacheRefresherBase(CacheHelper cacheHelper)
{
CacheHelper = cacheHelper;
}
/// <summary>
/// An event that is raised when cache is updated on an individual server
/// </summary>
@@ -44,6 +49,8 @@ namespace Umbraco.Core.Cache
public abstract string Name { get; }
protected CacheHelper CacheHelper { get; }
public virtual void RefreshAll()
{
OnCacheUpdated(Instance, new CacheRefresherEventArgs(null, MessageType.RefreshAll));
@@ -71,7 +78,7 @@ namespace Umbraco.Core.Cache
internal void ClearAllIsolatedCacheByEntityType<TEntity>()
where TEntity : class, IAggregateRoot
{
ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.ClearCache<TEntity>();
CacheHelper.IsolatedRuntimeCache.ClearCache<TEntity>();
}
}
}

View File

@@ -9,10 +9,16 @@ namespace Umbraco.Core.Cache
/// <remarks>Ensures that the correct events are raised when cache refreshing occurs.</remarks>
public abstract class JsonCacheRefresherBase<TInstance> : CacheRefresherBase<TInstance>, IJsonCacheRefresher
where TInstance : ICacheRefresher
{
{
protected JsonCacheRefresherBase(CacheHelper cacheHelper) : base(cacheHelper)
{
}
public virtual void Refresh(string json)
{
OnCacheUpdated(Instance, new CacheRefresherEventArgs(json, MessageType.RefreshByJson));
}
}
}

View File

@@ -10,6 +10,10 @@ namespace Umbraco.Core.Cache
public abstract class PayloadCacheRefresherBase<TInstance> : JsonCacheRefresherBase<TInstance>, IPayloadCacheRefresher
where TInstance : ICacheRefresher
{
protected PayloadCacheRefresherBase(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected abstract object Deserialize(string json);
public override void Refresh(string json)

View File

@@ -11,6 +11,10 @@ namespace Umbraco.Core.Cache
public abstract class TypedCacheRefresherBase<TInstanceType, TEntityType> : CacheRefresherBase<TInstanceType>, ICacheRefresher<TEntityType>
where TInstanceType : ICacheRefresher
{
protected TypedCacheRefresherBase(CacheHelper cacheHelper) : base(cacheHelper)
{
}
public virtual void Refresh(TEntityType instance)
{
OnCacheUpdated(Instance, new CacheRefresherEventArgs(instance, MessageType.RefreshByInstance));

View File

@@ -9,6 +9,11 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class ApplicationCacheRefresher : CacheRefresherBase<ApplicationCacheRefresher>
{
public ApplicationCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override ApplicationCacheRefresher Instance
{
get { return this; }
@@ -26,7 +31,7 @@ namespace Umbraco.Web.Cache
public override void RefreshAll()
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey);
CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey);
base.RefreshAll();
}
@@ -38,7 +43,7 @@ namespace Umbraco.Web.Cache
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey);
CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey);
base.Remove(id);
}

View File

@@ -9,6 +9,11 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class ApplicationTreeCacheRefresher : CacheRefresherBase<ApplicationTreeCacheRefresher>
{
public ApplicationTreeCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override ApplicationTreeCacheRefresher Instance
{
get { return this; }
@@ -26,7 +31,7 @@ namespace Umbraco.Web.Cache
public override void RefreshAll()
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
base.RefreshAll();
}
@@ -38,7 +43,7 @@ namespace Umbraco.Web.Cache
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
base.Remove(id);
}

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Web.Cache
{
private readonly ApplicationContext _applicationContext;
public ContentTypeCacheRefresher(ApplicationContext applicationContext)
public ContentTypeCacheRefresher(ApplicationContext applicationContext) : base(applicationContext.ApplicationCache)
{
_applicationContext = applicationContext;
}

View File

@@ -15,6 +15,10 @@ namespace Umbraco.Web.Cache
public sealed class DataTypeCacheRefresher : JsonCacheRefresherBase<DataTypeCacheRefresher>
{
public DataTypeCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
#region Static helpers
/// <summary>
@@ -98,13 +102,13 @@ namespace Umbraco.Web.Cache
ClearAllIsolatedCacheByEntityType<IMediaType>();
ClearAllIsolatedCacheByEntityType<IMember>();
ClearAllIsolatedCacheByEntityType<IMemberType>();
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
payloads.ForEach(payload =>
{
//clears the prevalue cache
var dataTypeCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IDataTypeDefinition>();
var dataTypeCache = CacheHelper.IsolatedRuntimeCache.GetCache<IDataTypeDefinition>();
if (dataTypeCache)
dataTypeCache.Result.ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.DataTypePreValuesCacheKey, payload.Id));

View File

@@ -11,6 +11,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class DictionaryCacheRefresher : CacheRefresherBase<DictionaryCacheRefresher>
{
public DictionaryCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override DictionaryCacheRefresher Instance
{
get { return this; }

View File

@@ -445,10 +445,10 @@ namespace Umbraco.Web.Cache
#region Xslt Cache
public static void ClearXsltCacheOnCurrentServer(this DistributedCache dc)
public static void ClearXsltCacheOnCurrentServer(this DistributedCache dc, CacheHelper cacheHelper)
{
if (UmbracoConfig.For.UmbracoSettings().Content.UmbracoLibraryCacheDuration <= 0) return;
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes("MS.Internal.Xml.XPath.XPathSelectionIterator");
cacheHelper.RuntimeCache.ClearCacheObjectTypes("MS.Internal.Xml.XPath.XPathSelectionIterator");
}
#endregion

View File

@@ -13,6 +13,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class DomainCacheRefresher : CacheRefresherBase<DomainCacheRefresher>
{
public DomainCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override DomainCacheRefresher Instance
{
get { return this; }
@@ -50,8 +54,10 @@ namespace Umbraco.Web.Cache
{
ClearAllIsolatedCacheByEntityType<IDomain>();
// SD: we need to clear the routes cache here!
//TODO: Fix this - if we keep this logic here to clear this cache, then we'll need to use IUmbracoContextAccessor since
// instances of the cache refreshers are singletons, not transient
//
// SD: we need to clear the routes cache here!
// zpqrtbnk: no, not here, in fact the caches should subsribe to refresh events else we
// are creating a nasty dependency - but keep it like that for the time being while
// SD is cleaning cache refreshers up.

View File

@@ -11,6 +11,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class LanguageCacheRefresher : CacheRefresherBase<LanguageCacheRefresher>
{
public LanguageCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override LanguageCacheRefresher Instance
{
get { return this; }

View File

@@ -19,6 +19,10 @@ namespace Umbraco.Web.Cache
/// </remarks>
public class MacroCacheRefresher : JsonCacheRefresherBase<MacroCacheRefresher>
{
public MacroCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
#region Static helpers
internal static string[] GetAllMacroCacheKeys()
@@ -170,10 +174,10 @@ namespace Umbraco.Web.Cache
public override void RefreshAll()
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheObjectTypes<MacroCacheContent>();
CacheHelper.RuntimeCache.ClearCacheObjectTypes<MacroCacheContent>();
GetAllMacroCacheKeys().ForEach(
prefix =>
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(prefix));
CacheHelper.RuntimeCache.ClearCacheByKeySearch(prefix));
ClearAllIsolatedCacheByEntityType<IMacro>();
@@ -188,9 +192,9 @@ namespace Umbraco.Web.Cache
{
GetCacheKeysForAlias(payload.Alias).ForEach(
alias =>
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(alias));
CacheHelper.RuntimeCache.ClearCacheByKeySearch(alias));
var macroRepoCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IMacro>();
var macroRepoCache = CacheHelper.IsolatedRuntimeCache.GetCache<IMacro>();
if (macroRepoCache)
{
macroRepoCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IMacro>(payload.Id));

View File

@@ -10,6 +10,7 @@ using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
using System.Linq;
using Umbraco.Core.Services;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
namespace Umbraco.Web.Cache
@@ -22,6 +23,13 @@ namespace Umbraco.Web.Cache
/// </remarks>
public class MediaCacheRefresher : JsonCacheRefresherBase<MediaCacheRefresher>
{
private readonly IMediaService _mediaService;
public MediaCacheRefresher(CacheHelper cacheHelper, IMediaService mediaService) : base(cacheHelper)
{
_mediaService = mediaService;
}
#region Static helpers
/// <summary>
@@ -137,34 +145,34 @@ namespace Umbraco.Web.Cache
public override void Refresh(int id)
{
ClearCache(FromMedia(ApplicationContext.Current.Services.MediaService.GetById(id), OperationType.Saved));
ClearCache(FromMedia(_mediaService.GetById(id), OperationType.Saved));
base.Refresh(id);
}
public override void Remove(int id)
{
ClearCache(FromMedia(ApplicationContext.Current.Services.MediaService.GetById(id),
ClearCache(FromMedia(_mediaService.GetById(id),
//NOTE: we'll just default to trashed for this one.
OperationType.Trashed));
base.Remove(id);
}
private static void ClearCache(params JsonPayload[] payloads)
private void ClearCache(params JsonPayload[] payloads)
{
if (payloads == null) return;
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
CacheHelper.ClearPartialViewCache();
payloads.ForEach(payload =>
{
var mediaCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IMedia>();
var mediaCache = CacheHelper.IsolatedRuntimeCache.GetCache<IMedia>();
//if there's no path, then just use id (this will occur on permanent deletion like emptying recycle bin)
if (payload.Path.IsNullOrWhiteSpace())
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
CacheHelper.RuntimeCache.ClearCacheByKeySearch(
string.Format("{0}_{1}", CacheKeys.MediaCacheKey, payload.Id));
}
else
@@ -177,12 +185,12 @@ namespace Umbraco.Web.Cache
mediaCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IMedia>(idPartAsInt));
}
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
CacheHelper.RuntimeCache.ClearCacheByKeySearch(
string.Format("{0}_{1}_True", CacheKeys.MediaCacheKey, idPart));
// Also clear calls that only query this specific item!
if (idPart == payload.Id.ToString(CultureInfo.InvariantCulture))
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
CacheHelper.RuntimeCache.ClearCacheByKeySearch(
string.Format("{0}_{1}", CacheKeys.MediaCacheKey, payload.Id));
}
}

View File

@@ -17,6 +17,9 @@ namespace Umbraco.Web.Cache
/// </remarks>
public class MemberCacheRefresher : TypedCacheRefresherBase<MemberCacheRefresher, IMember>
{
public MemberCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override MemberCacheRefresher Instance
{
@@ -59,16 +62,16 @@ namespace Umbraco.Web.Cache
private void ClearCache(int id)
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
CacheHelper.ClearPartialViewCache();
ApplicationContext.Current.ApplicationCache.RuntimeCache.
CacheHelper.RuntimeCache.
ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberLibraryCacheKey, id));
ApplicationContext.Current.ApplicationCache.RuntimeCache.
CacheHelper.RuntimeCache.
ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.MemberBusinessLogicCacheKey, id));
var memberCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IMember>();
var memberCache = CacheHelper.IsolatedRuntimeCache.GetCache<IMember>();
if (memberCache)
memberCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IMember>(id));
}

View File

@@ -6,11 +6,19 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Services;
namespace Umbraco.Web.Cache
{
public sealed class MemberGroupCacheRefresher : JsonCacheRefresherBase<MemberGroupCacheRefresher>
{
private readonly IMemberGroupService _memberGroupService;
public MemberGroupCacheRefresher(CacheHelper cacheHelper, IMemberGroupService memberGroupService) : base(cacheHelper)
{
_memberGroupService = memberGroupService;
}
#region Static helpers
/// <summary>
@@ -90,13 +98,13 @@ namespace Umbraco.Web.Cache
public override void Refresh(int id)
{
ClearCache(FromMemberGroup(ApplicationContext.Current.Services.MemberGroupService.GetById(id)));
ClearCache(FromMemberGroup(_memberGroupService.GetById(id)));
base.Refresh(id);
}
public override void Remove(int id)
{
ClearCache(FromMemberGroup(ApplicationContext.Current.Services.MemberGroupService.GetById(id)));
ClearCache(FromMemberGroup(_memberGroupService.GetById(id)));
base.Remove(id);
}
@@ -104,7 +112,7 @@ namespace Umbraco.Web.Cache
{
if (payloads == null) return;
var memberGroupCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IMemberGroup>();
var memberGroupCache = CacheHelper.IsolatedRuntimeCache.GetCache<IMemberGroup>();
payloads.ForEach(payload =>
{
if (payload != null && memberGroupCache)

View File

@@ -17,6 +17,9 @@ namespace Umbraco.Web.Cache
/// </remarks>
public class PageCacheRefresher : TypedCacheRefresherBase<PageCacheRefresher, IContent>
{
public PageCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override PageCacheRefresher Instance
{
@@ -59,10 +62,10 @@ namespace Umbraco.Web.Cache
/// <param name="id">The id.</param>
public override void Refresh(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.ClearPartialViewCache();
content.Instance.UpdateDocumentCache(id);
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer(CacheHelper);
base.Refresh(id);
}
@@ -72,30 +75,30 @@ namespace Umbraco.Web.Cache
/// <param name="id">The id.</param>
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.ClearPartialViewCache();
content.Instance.ClearDocumentCache(id);
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer(CacheHelper);
ClearAllIsolatedCacheByEntityType<PublicAccessEntry>();
base.Remove(id);
}
public override void Refresh(IContent instance)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.ClearPartialViewCache();
content.Instance.UpdateDocumentCache(new Document(instance));
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer(CacheHelper);
ClearAllIsolatedCacheByEntityType<PublicAccessEntry>();
base.Refresh(instance);
}
public override void Remove(IContent instance)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();
CacheHelper.ClearPartialViewCache();
content.Instance.ClearDocumentCache(new Document(instance));
DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer();
DistributedCache.Instance.ClearXsltCacheOnCurrentServer(CacheHelper);
ClearAllIsolatedCacheByEntityType<PublicAccessEntry>();
base.Remove(instance);
}

View File

@@ -10,6 +10,10 @@ namespace Umbraco.Web.Cache
{
public sealed class PublicAccessCacheRefresher : CacheRefresherBase<PublicAccessCacheRefresher>
{
public PublicAccessCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override PublicAccessCacheRefresher Instance
{
get { return this; }

View File

@@ -1,31 +0,0 @@
using System;
using System.ComponentModel;
using Umbraco.Core;
using Umbraco.Core.Cache;
namespace Umbraco.Web.Cache
{
/// <summary>
/// A cache refresher to ensure stylesheet cache is refreshed when stylesheets change
/// </summary>
[Obsolete("This is no longer used and will be removed in future versions")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class StylesheetCacheRefresher : CacheRefresherBase<StylesheetCacheRefresher>
{
protected override StylesheetCacheRefresher Instance
{
get { return this; }
}
public override Guid UniqueIdentifier
{
get { return new Guid(DistributedCache.StylesheetCacheRefresherId); }
}
public override string Name
{
get { return "Stylesheet cache refresher"; }
}
}
}

View File

@@ -1,31 +0,0 @@
using System;
using System.ComponentModel;
using Umbraco.Core;
using Umbraco.Core.Cache;
namespace Umbraco.Web.Cache
{
/// <summary>
/// A cache refresher to ensure stylesheet property cache is refreshed when stylesheet properties change
/// </summary>
[Obsolete("This is no longer used and will be removed in future versions")]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class StylesheetPropertyCacheRefresher : CacheRefresherBase<StylesheetPropertyCacheRefresher>
{
protected override StylesheetPropertyCacheRefresher Instance
{
get { return this; }
}
public override Guid UniqueIdentifier
{
get { return new Guid(DistributedCache.StylesheetPropertyCacheRefresherId); }
}
public override string Name
{
get { return "Stylesheet property cache refresher"; }
}
}
}

View File

@@ -16,6 +16,10 @@ namespace Umbraco.Web.Cache
/// </remarks>
public class TemplateCacheRefresher : CacheRefresherBase<TemplateCacheRefresher>
{
public TemplateCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override TemplateCacheRefresher Instance
{
get { return this; }
@@ -59,9 +63,9 @@ namespace Umbraco.Web.Cache
private void RemoveFromCache(int id)
{
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.IdToKeyCacheKey);
CacheHelper.RuntimeCache.ClearCacheByKeySearch(CacheKeys.KeyToIdCacheKey);
CacheHelper.RuntimeCache.ClearCacheItem(
string.Format("{0}{1}", CacheKeys.TemplateFrontEndCacheKey, id));
//need to clear the runtime cache for templates

View File

@@ -16,6 +16,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class UnpublishedPageCacheRefresher : TypedCacheRefresherBase<UnpublishedPageCacheRefresher, IContent>, IJsonCacheRefresher
{
public UnpublishedPageCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override UnpublishedPageCacheRefresher Instance
{
get { return this; }
@@ -139,7 +143,7 @@ namespace Umbraco.Web.Cache
private void ClearRepositoryCacheItemById(int id)
{
var contentCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IContent>();
var contentCache = CacheHelper.IsolatedRuntimeCache.GetCache<IContent>();
if (contentCache)
{
contentCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IContent>(id));

View File

@@ -12,6 +12,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class UserCacheRefresher : CacheRefresherBase<UserCacheRefresher>
{
public UserCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override UserCacheRefresher Instance
{
get { return this; }
@@ -43,7 +47,7 @@ namespace Umbraco.Web.Cache
public override void Remove(int id)
{
var userCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IUser>();
var userCache = CacheHelper.IsolatedRuntimeCache.GetCache<IUser>();
if (userCache)
userCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IUser>(id));
@@ -55,7 +59,7 @@ namespace Umbraco.Web.Cache
private Attempt<IRuntimeCacheProvider> UserPermissionsCache
{
get { return ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<EntityPermission>(); }
get { return CacheHelper.IsolatedRuntimeCache.GetCache<EntityPermission>(); }
}
}

View File

@@ -14,6 +14,10 @@ namespace Umbraco.Web.Cache
/// </remarks>
public sealed class UserPermissionsCacheRefresher : CacheRefresherBase<UserPermissionsCacheRefresher>
{
public UserPermissionsCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override UserPermissionsCacheRefresher Instance
{
get { return this; }
@@ -52,7 +56,7 @@ namespace Umbraco.Web.Cache
private Attempt<IRuntimeCacheProvider> UserPermissionsCache
{
get { return ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<EntityPermission>(); }
get { return CacheHelper.IsolatedRuntimeCache.GetCache<EntityPermission>(); }
}
}
}

View File

@@ -12,6 +12,10 @@ namespace Umbraco.Web.Cache
/// </summary>
public sealed class UserTypeCacheRefresher : CacheRefresherBase<UserTypeCacheRefresher>
{
public UserTypeCacheRefresher(CacheHelper cacheHelper) : base(cacheHelper)
{
}
protected override UserTypeCacheRefresher Instance
{
get { return this; }
@@ -35,7 +39,7 @@ namespace Umbraco.Web.Cache
public override void Refresh(int id)
{
var userTypeCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IUserType>();
var userTypeCache = CacheHelper.IsolatedRuntimeCache.GetCache<IUserType>();
if (userTypeCache)
userTypeCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IUserType>(id));
base.Refresh(id);
@@ -43,7 +47,7 @@ namespace Umbraco.Web.Cache
public override void Remove(int id)
{
var userTypeCache = ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<IUserType>();
var userTypeCache = CacheHelper.IsolatedRuntimeCache.GetCache<IUserType>();
if (userTypeCache)
userTypeCache.Result.ClearCacheItem(RepositoryBase.GetCacheIdKey<IUserType>(id));
base.Remove(id);

View File

@@ -479,8 +479,6 @@
<Compile Include="Cache\MemberGroupCacheRefresher.cs" />
<Compile Include="Cache\PageCacheRefresher.cs" />
<Compile Include="Cache\PublicAccessCacheRefresher.cs" />
<Compile Include="Cache\StylesheetCacheRefresher.cs" />
<Compile Include="Cache\StylesheetPropertyCacheRefresher.cs" />
<Compile Include="Cache\TemplateCacheRefresher.cs" />
<Compile Include="Cache\UnpublishedPageCacheRefresher.cs" />
<Compile Include="Cache\UserCacheRefresher.cs" />