Moves clearing of the routes cache for when domains are changed to the DomainCacheRefresher.

This commit is contained in:
Shannon Deminick
2013-03-22 05:15:58 +06:00
parent e8dd56786b
commit 8cdfba42d5
3 changed files with 16 additions and 11 deletions

View File

@@ -220,8 +220,7 @@ namespace Umbraco.Web.Cache
if (payloads.Any(x => x.Type == typeof(IContentType).Name)
&& !payloads.All(x => x.IsNew)) //if they are all new then don't proceed
{
//we need to clear the routes cache here!
//TODO: Is there a better way to handle this without casting ?
//we need to clear the routes cache here!
var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache;
if (contentCache != null)
{

View File

@@ -1,6 +1,8 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.LegacyXmlCache;
namespace Umbraco.Web.Cache
{
@@ -26,14 +28,25 @@ namespace Umbraco.Web.Cache
public override void Refresh(int id)
{
ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey);
ClearCache();
base.Refresh(id);
}
public override void Remove(int id)
{
ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey);
ClearCache();
base.Remove(id);
}
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();
}
}
}
}

View File

@@ -49,13 +49,6 @@ namespace Umbraco.Web.PublishedCache.LegacyXmlCache
global::umbraco.content.AfterUpdateDocumentCache += (sender, e) => Clear();
global::umbraco.content.AfterClearDocumentCache += (sender, e) => Clear();
// domains - whenever a domain change we must clear the cache
// because routes contain the id of root nodes of domains
// TODO could we do partial updates instead of clearing the whole cache?
global::umbraco.cms.businesslogic.web.Domain.AfterDelete += (sender, e) => Clear();
global::umbraco.cms.businesslogic.web.Domain.AfterSave += (sender, e) => Clear();
global::umbraco.cms.businesslogic.web.Domain.New += (sender, e) => Clear();
// FIXME
// the content class needs to be refactored - at the moment
// content.XmlContentInternal setter does not trigger any event