2013-03-22 00:49:07 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Cache;
|
2013-03-22 05:15:58 +06:00
|
|
|
|
using Umbraco.Web.PublishedCache;
|
|
|
|
|
|
using Umbraco.Web.PublishedCache.LegacyXmlCache;
|
2013-03-22 00:49:07 +06:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Cache
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A cache refresher to ensure language cache is refreshed when languages change
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class DomainCacheRefresher : CacheRefresherBase<DomainCacheRefresher>
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override DomainCacheRefresher Instance
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return this; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Guid UniqueIdentifier
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return new Guid(DistributedCache.DomainCacheRefresherId); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "Domain cache refresher"; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Refresh(int id)
|
|
|
|
|
|
{
|
2013-03-22 05:15:58 +06:00
|
|
|
|
ClearCache();
|
2013-03-22 00:49:07 +06:00
|
|
|
|
base.Refresh(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Remove(int id)
|
|
|
|
|
|
{
|
2013-03-22 05:15:58 +06:00
|
|
|
|
ClearCache();
|
2013-03-22 00:49:07 +06:00
|
|
|
|
base.Remove(id);
|
|
|
|
|
|
}
|
2013-03-22 05:15:58 +06:00
|
|
|
|
|
|
|
|
|
|
private void ClearCache()
|
|
|
|
|
|
{
|
|
|
|
|
|
ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey);
|
|
|
|
|
|
//we need to clear the routes cache here!
|
|
|
|
|
|
var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache;
|
|
|
|
|
|
if (contentCache != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
contentCache.RoutesCache.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|