2013-03-22 00:49:07 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Cache;
|
2015-07-27 12:53:09 +02:00
|
|
|
|
using Umbraco.Core.Models;
|
2015-01-29 15:39:41 +11:00
|
|
|
|
using Umbraco.Core.Persistence.Repositories;
|
2013-03-22 05:15:58 +06:00
|
|
|
|
using Umbraco.Web.PublishedCache;
|
2013-03-22 15:02:26 -01:00
|
|
|
|
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
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()
|
2016-01-06 18:08:14 +01:00
|
|
|
|
{
|
2016-01-07 19:27:59 +01:00
|
|
|
|
ClearAllIsolatedCacheByEntityType<IDomain>();
|
2015-01-29 15:39:41 +11:00
|
|
|
|
|
2013-03-31 18:40:55 -02:00
|
|
|
|
// 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.
|
2013-05-02 14:24:27 -10:00
|
|
|
|
if (UmbracoContext.Current != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var contentCache = UmbracoContext.Current.ContentCache.InnerCache as PublishedContentCache;
|
|
|
|
|
|
if (contentCache != null)
|
|
|
|
|
|
contentCache.RoutesCache.Clear();
|
|
|
|
|
|
}
|
2013-03-22 05:15:58 +06:00
|
|
|
|
}
|
2013-03-22 00:49:07 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|