Files
Umbraco-CMS/src/Umbraco.Web/Cache/UserCacheRefresher.cs
Shannon Deminick 296c24f829 Fixes: #U4-2042 - ensures users cannot continue to user the back office after they've been disabled and
ensures that the user context cache is cleared when users are saved which will work in LB environments.
Changes more HttpRuntime.Cache dependencies to ApplicationContext.Current.ApplicationCache.
2013-04-04 02:11:31 +06:00

49 lines
1.5 KiB
C#

using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
using umbraco.interfaces;
namespace Umbraco.Web.Cache
{
/// <summary>
/// Handles User cache invalidation/refreshing
/// </summary>
public sealed class UserCacheRefresher : CacheRefresherBase<UserCacheRefresher>
{
protected override UserCacheRefresher Instance
{
get { return this; }
}
public override Guid UniqueIdentifier
{
get { return Guid.Parse(DistributedCache.UserCacheRefresherId); }
}
public override string Name
{
get { return "User cache refresher"; }
}
public override void RefreshAll()
{
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(CacheKeys.UserCacheKey);
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(CacheKeys.UserContextCacheKey);
}
public override void Refresh(int id)
{
Remove(id);
}
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.ClearCacheItem(string.Format("{0}{1}", CacheKeys.UserCacheKey, id));
//we need to clear all UserContextCacheKey since we cannot invalidate based on ID since the cache is done so based
//on the current contextId stored in the database
ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch(CacheKeys.UserContextCacheKey);
}
}
}