2013-08-12 15:06:12 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Cache;
|
2016-01-06 18:08:14 +01:00
|
|
|
|
using Umbraco.Core.Models.Membership;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used only to invalidate the user permissions cache
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// The UserCacheRefresher will also clear a user's permissions cache, this refresher is for invalidating only permissions
|
|
|
|
|
|
/// for users/content, not the users themselves.
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public sealed class UserPermissionsCacheRefresher : CacheRefresherBase<UserPermissionsCacheRefresher>
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override UserPermissionsCacheRefresher Instance
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Guid UniqueIdentifier
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Guid.Parse(DistributedCache.UserPermissionsCacheRefresherId); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "User permissions cache refresher"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void RefreshAll()
|
|
|
|
|
|
{
|
2016-01-06 18:08:14 +01:00
|
|
|
|
if (UserPermissionsCache)
|
|
|
|
|
|
UserPermissionsCache.Result.ClearCacheByKeySearch(CacheKeys.UserPermissionsCacheKey);
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.RefreshAll();
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Refresh(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
Remove(id);
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.Refresh(id);
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Remove(int id)
|
|
|
|
|
|
{
|
2016-01-06 18:08:14 +01:00
|
|
|
|
if (UserPermissionsCache)
|
2016-02-25 17:39:34 +01:00
|
|
|
|
UserPermissionsCache.Result.ClearCacheByKeySearch(string.Format("{0}{1}", CacheKeys.UserPermissionsCacheKey, id));
|
2014-03-20 12:36:13 +11:00
|
|
|
|
base.Remove(id);
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
2016-01-06 18:08:14 +01:00
|
|
|
|
|
|
|
|
|
|
private Attempt<IRuntimeCacheProvider> UserPermissionsCache
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ApplicationContext.Current.ApplicationCache.IsolatedRuntimeCache.GetCache<EntityPermission>(); }
|
|
|
|
|
|
}
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
2013-07-09 11:47:46 +10:00
|
|
|
|
}
|