diff --git a/src/Umbraco.Core/CacheHelper.cs b/src/Umbraco.Core/CacheHelper.cs
index 4896d5fad0..428c88d01c 100644
--- a/src/Umbraco.Core/CacheHelper.cs
+++ b/src/Umbraco.Core/CacheHelper.cs
@@ -91,7 +91,27 @@ namespace Umbraco.Core
ClearCacheItem((string)c.Key);
}
}
-
+
+ ///
+ /// Gets (and adds if necessary) an item from the cache with all of the default parameters
+ ///
+ ///
+ ///
+ ///
+ ///
+ public TT GetCacheItem(string cacheKey, Func getCacheItem)
+ {
+ return GetCacheItem(cacheKey, CacheItemPriority.Normal, null, null, null, getCacheItem, Locker);
+ }
+
+ ///
+ /// Gets (and adds if necessary) an item from the cache with the specified absolute expiration date (from NOW)
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public TT GetCacheItem(string cacheKey,
TimeSpan timeout, Func getCacheItem)
{
@@ -138,7 +158,7 @@ namespace Umbraco.Core
///
internal TT GetCacheItem(string cacheKey,
CacheItemPriority priority, CacheItemRemovedCallback refreshAction,
- CacheDependency cacheDependency, TimeSpan timeout, Func getCacheItem, object syncLock)
+ CacheDependency cacheDependency, TimeSpan? timeout, Func getCacheItem, object syncLock)
{
var result = _cache.Get(cacheKey);
if (result == null)
@@ -152,7 +172,9 @@ namespace Umbraco.Core
if (result != null)
{
//we use Insert instead of add if for some crazy reason there is now a cache with the cache key in there, it will just overwrite it.
- _cache.Insert(cacheKey, result, cacheDependency, DateTime.Now.Add(timeout), TimeSpan.Zero, priority, refreshAction);
+ _cache.Insert(cacheKey, result, cacheDependency,
+ timeout == null ? Cache.NoAbsoluteExpiration : DateTime.Now.Add(timeout.Value),
+ TimeSpan.Zero, priority, refreshAction);
}
}
}
diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index 42fed5edce..0cc47263a6 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -98,7 +98,7 @@ namespace Umbraco.Core
{
CanResolveBeforeFrozen = true
};
- //dd custom types here that are internal
+ //add custom types here that are internal
ApplicationEventsResolver.Current.AddType();
}
diff --git a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
index 7f5b6f6365..fcfc1f3d55 100644
--- a/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
+++ b/src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
@@ -39,10 +39,5 @@ namespace Umbraco.Core.ObjectResolution
get { return false; }
}
- protected override bool SupportsRemove
- {
- get { return false; }
- }
-
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs b/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs
index eae56a9604..927d6f878e 100644
--- a/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs
+++ b/src/Umbraco.Core/ObjectResolution/LazyManyObjectsResolverbase.cs
@@ -99,6 +99,7 @@ namespace Umbraco.Core.ObjectResolution
private readonly List> _lazyTypeList = new List>();
private readonly List>> _typeListProducerList = new List>>();
+ private readonly List _typesToRemoveOnResolved = new List();
private List _resolvedTypes = null;
private readonly ReaderWriterLockSlim _resolvedTypesLock = new ReaderWriterLockSlim();
@@ -130,19 +131,21 @@ namespace Umbraco.Core.ObjectResolution
{
if (_resolvedTypes == null)
{
+ lck.UpgradeToWriteLock();
+
+ _resolvedTypes = new List();
+
// get the types by evaluating the lazy & producers
var types = new List();
types.AddRange(_lazyTypeList.Select(x => x.Value));
types.AddRange(_typeListProducerList.SelectMany(x => x()));
- lck.UpgradeToWriteLock();
-
- _resolvedTypes = new List();
-
// we need to validate each resolved type now since we could
// not do it before evaluating the lazy & producers
- foreach (var type in types)
- AddValidAndNoDuplicate(_resolvedTypes, type);
+ foreach (var type in types.Where(x => !_typesToRemoveOnResolved.Contains(x)))
+ {
+ AddValidAndNoDuplicate(_resolvedTypes, type);
+ }
}
return _resolvedTypes;
@@ -150,8 +153,12 @@ namespace Umbraco.Core.ObjectResolution
}
}
- // ensures that type is valid and not a duplicate
- // then appends the type to the end of the list
+ ///
+ /// Ensures that type is valid and not a duplicate
+ /// then appends the type to the end of the list
+ ///
+ ///
+ ///
private void AddValidAndNoDuplicate(List list, Type type)
{
EnsureCorrectType(type);
@@ -165,6 +172,19 @@ namespace Umbraco.Core.ObjectResolution
#region Types collection manipulation
+ ///
+ /// Once types are resolved any types that have been added with this method will be removed once the types have been lazily resolved.
+ ///
+ ///
+ /// The resolver must support removals for this method to work
+ ///
+ public override void RemoveType(Type value)
+ {
+ EnsureSupportsRemove();
+
+ _typesToRemoveOnResolved.Add(value);
+ }
+
///
/// Lazily adds types from lazy types.
///
@@ -216,7 +236,7 @@ namespace Umbraco.Core.ObjectResolution
///
/// Lazily adds a type from an actual type.
///
- /// The actual type, to add.
+ /// The actual type, to add.
/// The type is converted to a lazy type.
public override void AddType(Type value)
{
@@ -241,14 +261,6 @@ namespace Umbraco.Core.ObjectResolution
#region Types collection manipulation support
- ///
- /// Gets a false value indicating that the resolver does NOT support removing types.
- ///
- protected override bool SupportsRemove
- {
- get { return false; }
- }
-
///
/// Gets a false value indicating that the resolver does NOT support inserting types.
///
diff --git a/src/Umbraco.Tests/Resolvers/LazyManyObjectResolverTests.cs b/src/Umbraco.Tests/Resolvers/LazyManyObjectResolverTests.cs
index 39f4397099..66549d82dd 100644
--- a/src/Umbraco.Tests/Resolvers/LazyManyObjectResolverTests.cs
+++ b/src/Umbraco.Tests/Resolvers/LazyManyObjectResolverTests.cs
@@ -118,6 +118,22 @@ namespace Umbraco.Tests.Resolvers
var values = resolver.Objects;
});
}
+
+ [Test]
+ public void LazyResolverSupportsRemove()
+ {
+ Func> types = () => new[] { typeof(TransientObject3), typeof(TransientObject2), typeof(TransientObject1) };
+
+ var resolver = new LazyResolver(types);
+
+ resolver.RemoveType(typeof(TransientObject3));
+
+ Resolution.Freeze();
+
+ var values = resolver.Objects;
+ Assert.IsFalse(values.Select(x => x.GetType()).Contains(typeof(TransientObject3)));
+ Assert.IsTrue(values.Select(x => x.GetType()).ContainsAll(new[] { typeof(TransientObject2), typeof(TransientObject1) }));
+ }
#region Test classes
diff --git a/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs b/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs
new file mode 100644
index 0000000000..704817eb99
--- /dev/null
+++ b/src/Umbraco.Web/Cache/LibraryCacheRefresher.cs
@@ -0,0 +1,76 @@
+using Umbraco.Core;
+using Umbraco.Core.Services;
+using umbraco;
+using umbraco.cms.businesslogic;
+using umbraco.cms.businesslogic.member;
+using System.Linq;
+
+namespace Umbraco.Web.Cache
+{
+ ///
+ /// Special class made to listen to save events on objects where umbraco.library caches some of their objects
+ ///
+ public class LibraryCacheRefresher : ApplicationEventHandler
+ {
+ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
+ {
+ if (UmbracoSettings.UmbracoLibraryCacheDuration <= 0) return;
+
+
+ Member.AfterSave += MemberAfterSave;
+ Member.BeforeDelete += MemberBeforeDelete;
+
+ //NOTE: this should not need to be done, the SavedCollection event shouldn't even exist!! :(
+ MediaService.SavedCollection += MediaServiceSavedCollection;
+ MediaService.Saved += MediaServiceSaved;
+ MediaService.Deleting += MediaServiceDeleting;
+ MediaService.Moved += MediaServiceMoved;
+ MediaService.Trashed += MediaService_Trashed;
+ }
+
+ static void MediaService_Trashed(IMediaService sender, Core.Events.MoveEventArgs e)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(e.Entity.Id);
+ }
+
+ static void MediaServiceMoved(IMediaService sender, Core.Events.MoveEventArgs e)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(e.Entity.Id);
+ }
+
+ static void MediaServiceDeleting(IMediaService sender, Core.Events.DeleteEventArgs e)
+ {
+ foreach (var item in e.DeletedEntities)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(item.Id);
+ }
+ }
+
+ //NOTE: this should not need to be done, the SavedCollection event shouldn't even exist!! :(
+ static void MediaServiceSavedCollection(IMediaService sender, Core.Events.SaveEventArgs> e)
+ {
+ foreach (var item in e.SavedEntities.SelectMany(x => x))
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(item.Id);
+ }
+ }
+
+ static void MediaServiceSaved(IMediaService sender, Core.Events.SaveEventArgs e)
+ {
+ foreach (var item in e.SavedEntities)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(item.Id);
+ }
+ }
+
+ static void MemberBeforeDelete(Member sender, DeleteEventArgs e)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(sender.Id);
+ }
+
+ static void MemberAfterSave(Member sender, SaveEventArgs e)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(sender.Id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/MacroCacheRefresher.cs b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
new file mode 100644
index 0000000000..f4cf173e4b
--- /dev/null
+++ b/src/Umbraco.Web/Cache/MacroCacheRefresher.cs
@@ -0,0 +1,44 @@
+using System;
+using umbraco;
+using umbraco.interfaces;
+
+namespace Umbraco.Web.Cache
+{
+ public class MacroCacheRefresher : ICacheRefresher
+ {
+ public string Name
+ {
+ get
+ {
+ return "Macro cache refresher";
+ }
+ }
+
+ public Guid UniqueIdentifier
+ {
+ get
+ {
+ return new Guid("7B1E683C-5F34-43dd-803D-9699EA1E98CA");
+ }
+ }
+
+ public void RefreshAll()
+ {
+ }
+
+ public void Refresh(Guid id)
+ {
+ }
+
+ void ICacheRefresher.Refresh(int id)
+ {
+ macro.GetMacro(id).removeFromCache();
+ }
+
+ void ICacheRefresher.Remove(int id)
+ {
+ macro.GetMacro(id).removeFromCache();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/MediaLibraryRefreshers.cs b/src/Umbraco.Web/Cache/MediaLibraryRefreshers.cs
new file mode 100644
index 0000000000..6bcf734196
--- /dev/null
+++ b/src/Umbraco.Web/Cache/MediaLibraryRefreshers.cs
@@ -0,0 +1,38 @@
+using System;
+using Umbraco.Core;
+using umbraco.interfaces;
+
+namespace Umbraco.Web.Cache
+{
+ public class MediaLibraryRefreshers : ICacheRefresher
+ {
+
+ public Guid UniqueIdentifier
+ {
+ get { return new Guid("B29286DD-2D40-4DDB-B325-681226589FEC"); }
+ }
+
+ public string Name
+ {
+ get { return "Clears Media Cache from umbraco.library"; }
+ }
+
+ public void RefreshAll()
+ {
+ }
+
+ public void Refresh(int id)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(id, false);
+ }
+
+ public void Remove(int id)
+ {
+ }
+
+ public void Refresh(Guid id)
+ {
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/MemberLibraryRefreshers.cs b/src/Umbraco.Web/Cache/MemberLibraryRefreshers.cs
new file mode 100644
index 0000000000..b65362c69c
--- /dev/null
+++ b/src/Umbraco.Web/Cache/MemberLibraryRefreshers.cs
@@ -0,0 +1,38 @@
+using System;
+using Umbraco.Core;
+using umbraco.interfaces;
+
+namespace Umbraco.Web.Cache
+{
+ public class MemberLibraryRefreshers : ICacheRefresher
+ {
+
+ public Guid UniqueIdentifier
+ {
+ get { return new Guid("E285DF34-ACDC-4226-AE32-C0CB5CF388DA"); }
+ }
+
+ public string Name
+ {
+ get { return "Clears Member Cache from umbraco.library"; }
+ }
+
+ public void RefreshAll()
+ {
+ }
+
+ public void Refresh(int id)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(id, false);
+ }
+
+ public void Remove(int id)
+ {
+ }
+
+ public void Refresh(Guid id)
+ {
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Cache/PageCacheRefresher.cs b/src/Umbraco.Web/Cache/PageCacheRefresher.cs
new file mode 100644
index 0000000000..8ab1b2f636
--- /dev/null
+++ b/src/Umbraco.Web/Cache/PageCacheRefresher.cs
@@ -0,0 +1,73 @@
+using System;
+using umbraco;
+using umbraco.interfaces;
+using umbraco.presentation.cache;
+
+namespace Umbraco.Web.Cache
+{
+ ///
+ /// PageCacheRefresher is the standard CacheRefresher used by Load-Balancing in Umbraco.
+ ///
+ ///
+ /// If Load balancing is enabled (by default disabled, is set in umbracoSettings.config) PageCacheRefresher will be called
+ /// everytime content is added/updated/removed to ensure that the content cache is identical on all load balanced servers
+ ///
+ public class PageCacheRefresher : ICacheRefresher
+ {
+ ///
+ /// Gets the unique identifier of the CacheRefresher.
+ ///
+ /// The unique identifier.
+ public Guid UniqueIdentifier
+ {
+ get
+ {
+ return new Guid("27AB3022-3DFA-47b6-9119-5945BC88FD66");
+ }
+ }
+
+ ///
+ /// Gets the name of the CacheRefresher
+ ///
+ /// The name.
+ public string Name
+ {
+ get { return "Page Refresher"; }
+ }
+
+ ///
+ /// Refreshes all nodes in umbraco.
+ ///
+ public void RefreshAll()
+ {
+ content.Instance.RefreshContentFromDatabaseAsync();
+ }
+
+ ///
+ /// Not used with content.
+ ///
+ /// The id.
+ public void Refresh(Guid id)
+ {
+ // Not used when pages
+ }
+
+ ///
+ /// Refreshes the cache for the node with specified id
+ ///
+ /// The id.
+ public void Refresh(int id)
+ {
+ content.Instance.UpdateDocumentCache(id);
+ }
+
+ ///
+ /// Removes the node with the specified id from the cache
+ ///
+ /// The id.
+ public void Remove(int id)
+ {
+ content.Instance.ClearDocumentCache(id);
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs
new file mode 100644
index 0000000000..cdf3e6e2a5
--- /dev/null
+++ b/src/Umbraco.Web/Cache/TemplateCacheRefresher.cs
@@ -0,0 +1,45 @@
+using System;
+using Umbraco.Core;
+using umbraco;
+using umbraco.interfaces;
+
+namespace Umbraco.Web.Cache
+{
+ public class TemplateCacheRefresher : ICacheRefresher
+ {
+ public string Name
+ {
+ get
+ {
+ return "Template cache refresher";
+ }
+ }
+
+ public Guid UniqueIdentifier
+ {
+ get
+ {
+ return new Guid("DD12B6A0-14B9-46e8-8800-C154F74047C8");
+ }
+ }
+
+ public void RefreshAll()
+ {
+ }
+
+ public void Refresh(Guid id)
+ {
+ }
+
+ public void Refresh(int id)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(id);
+ }
+
+ public void Remove(int id)
+ {
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(id);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/CacheHelperExtensions.cs b/src/Umbraco.Web/CacheHelperExtensions.cs
index 1c22d9557b..f1893c1d4a 100644
--- a/src/Umbraco.Web/CacheHelperExtensions.cs
+++ b/src/Umbraco.Web/CacheHelperExtensions.cs
@@ -4,8 +4,10 @@ using System.Web.Caching;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Umbraco.Core;
+using Umbraco.Core.Configuration;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.web;
+using umbraco.presentation.cache;
namespace Umbraco.Web
{
@@ -15,14 +17,10 @@ namespace Umbraco.Web
///
internal static class CacheHelperExtensions
{
-
///
/// Application event handler to bind to events to clear the cache for the cache helper extensions
- ///
- ///
- /// This would be better left internal, however
- ///
- public sealed class CacheHelperApplicationEventListener : ApplicationEventHandler
+ ///
+ internal sealed class CacheHelperApplicationEventListener : ApplicationEventHandler
{
protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
@@ -47,6 +45,85 @@ namespace Umbraco.Web
}
public const string PartialViewCacheKey = "Umbraco.Web.PartialViewCacheKey";
+ private const string TemplateCacheKey = "template";
+
+ ///
+ /// Clears the cache for a template
+ ///
+ ///
+ ///
+ public static void ClearCacheForTemplate(this CacheHelper cacheHelper, int templateId)
+ {
+ cacheHelper.ClearCacheByKeySearch(
+ string.Format("{0}{1}", TemplateCacheKey, templateId));
+ }
+
+ ///
+ /// Clears the library cache for media
+ ///
+ ///
+ ///
+ ///
+ /// If set to false, this will only clear the library cache for the current server, not all servers registered in the
+ /// server farm. In most cases if you are clearing cache you would probably clear it on all servers.
+ ///
+ public static void ClearLibraryCacheForMedia(this CacheHelper cacheHelper, int mediaId, bool allServers = true)
+ {
+ const string getmediaCacheKey = "GetMedia";
+
+ if (allServers && UmbracoSettings.UseDistributedCalls)
+ {
+ dispatcher.Refresh(
+ new Guid("B29286DD-2D40-4DDB-B325-681226589FEC"),
+ mediaId);
+ }
+ else
+ {
+ var m = new global::umbraco.cms.businesslogic.media.Media(mediaId);
+ if (m.nodeObjectType == global::umbraco.cms.businesslogic.media.Media._objectType)
+ {
+ foreach (string id in m.Path.Split(','))
+ {
+ cacheHelper.ClearCacheByKeySearch(
+ string.Format("UL_{0}_{1}_True", getmediaCacheKey, id));
+
+ // Also clear calls that only query this specific item!
+ if (id == m.Id.ToString())
+ cacheHelper.ClearCacheByKeySearch(
+ string.Format("UL_{0}_{1}", getmediaCacheKey, id));
+
+ }
+ }
+ }
+ }
+
+ ///
+ /// Clears the library cache for members
+ ///
+ ///
+ ///
+ ///
+ /// If set to false, this will only clear the library cache for the current server, not all servers registered in the
+ /// server farm. In most cases if you are clearing cache you would probably clear it on all servers.
+ ///
+ public static void ClearLibraryCacheForMember(this CacheHelper cacheHelper, int memberId, bool allServers = true)
+ {
+ const string getmemberCacheKey = "GetMember";
+
+ if (allServers && UmbracoSettings.UseDistributedCalls)
+ {
+ dispatcher.Refresh(
+ new Guid("E285DF34-ACDC-4226-AE32-C0CB5CF388DA"),
+ memberId);
+ }
+ else
+ {
+ cacheHelper.ClearCacheByKeySearch(
+ string.Format("UL_{0}_{1}", getmemberCacheKey, memberId));
+ }
+
+
+ }
///
/// Outputs and caches a partial view in MVC
diff --git a/src/Umbraco.Web/Search/ExamineEvents.cs b/src/Umbraco.Web/Search/ExamineEvents.cs
index a00be7d56f..ce7c4de096 100644
--- a/src/Umbraco.Web/Search/ExamineEvents.cs
+++ b/src/Umbraco.Web/Search/ExamineEvents.cs
@@ -60,11 +60,14 @@ namespace Umbraco.Web.Search
return;
MediaService.Saved += MediaServiceSaved;
+ //NOTE: this should not need to be done, the SavedCollection event shouldn't even exist!! :(
+ MediaService.SavedCollection += MediaServiceSavedCollection;
MediaService.Deleted += MediaServiceDeleted;
MediaService.Moved += MediaServiceMoved;
+ MediaService.Trashed += MediaServiceTrashed;
ContentService.Saved += ContentServiceSaved;
- ContentService.Deleted += ContentService_Deleted;
- ContentService.Moved += ContentService_Moved;
+ ContentService.Deleted += ContentServiceDeleted;
+ ContentService.Moved += ContentServiceMoved;
//These should only fire for providers that DONT have SupportUnpublishedContent set to true
content.AfterUpdateDocumentCache += ContentAfterUpdateDocumentCache;
@@ -85,14 +88,30 @@ namespace Umbraco.Web.Search
}
}
+ //NOTE: this should not need to be done, the SavedCollection event shouldn't even exist!! :(
[SecuritySafeCritical]
- void ContentService_Moved(IContentService sender, Umbraco.Core.Events.MoveEventArgs e)
+ static void MediaServiceSavedCollection(IMediaService sender, Core.Events.SaveEventArgs> e)
+ {
+ foreach (var item in e.SavedEntities.SelectMany(x => x))
+ {
+ IndexMedia(item);
+ }
+ }
+
+ [SecuritySafeCritical]
+ static void MediaServiceTrashed(IMediaService sender, Core.Events.MoveEventArgs e)
+ {
+ IndexMedia(e.Entity);
+ }
+
+ [SecuritySafeCritical]
+ static void ContentServiceMoved(IContentService sender, Umbraco.Core.Events.MoveEventArgs e)
{
IndexConent(e.Entity);
}
[SecuritySafeCritical]
- void ContentService_Deleted(IContentService sender, Umbraco.Core.Events.DeleteEventArgs e)
+ static void ContentServiceDeleted(IContentService sender, Umbraco.Core.Events.DeleteEventArgs e)
{
e.DeletedEntities.ForEach(
content =>
@@ -102,19 +121,19 @@ namespace Umbraco.Web.Search
}
[SecuritySafeCritical]
- void ContentServiceSaved(IContentService sender, Umbraco.Core.Events.SaveEventArgs e)
+ static void ContentServiceSaved(IContentService sender, Umbraco.Core.Events.SaveEventArgs e)
{
e.SavedEntities.ForEach(IndexConent);
}
[SecuritySafeCritical]
- void MediaServiceMoved(IMediaService sender, Umbraco.Core.Events.MoveEventArgs e)
+ static void MediaServiceMoved(IMediaService sender, Umbraco.Core.Events.MoveEventArgs e)
{
IndexMedia(e.Entity);
}
[SecuritySafeCritical]
- void MediaServiceDeleted(IMediaService sender, Umbraco.Core.Events.DeleteEventArgs e)
+ static void MediaServiceDeleted(IMediaService sender, Umbraco.Core.Events.DeleteEventArgs e)
{
e.DeletedEntities.ForEach(
media =>
@@ -124,7 +143,7 @@ namespace Umbraco.Web.Search
}
[SecuritySafeCritical]
- void MediaServiceSaved(IMediaService sender, Umbraco.Core.Events.SaveEventArgs e)
+ static void MediaServiceSaved(IMediaService sender, Umbraco.Core.Events.SaveEventArgs e)
{
e.SavedEntities.ForEach(IndexMedia);
}
@@ -205,14 +224,14 @@ namespace Umbraco.Web.Search
}
- private void IndexMedia(IMedia sender)
+ private static void IndexMedia(IMedia sender)
{
ExamineManager.Instance.ReIndexNode(
sender.ToXml(), "media",
ExamineManager.Instance.IndexProviderCollection.OfType().Where(x => x.EnableDefaultEventHandler));
}
- private void IndexConent(IContent sender)
+ private static void IndexConent(IContent sender)
{
ExamineManager.Instance.ReIndexNode(
sender.ToXml(), "content",
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index e3d3daa97d..63eacd0568 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -244,6 +244,12 @@
+
+
+
+
+
+
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index b8cc3a346c..907a8efdb8 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -18,6 +18,7 @@ using Umbraco.Web.PropertyEditors;
using Umbraco.Web.Routing;
using umbraco.businesslogic;
using umbraco.cms.businesslogic;
+using umbraco.presentation.cache;
namespace Umbraco.Web
@@ -81,6 +82,8 @@ namespace Umbraco.Web
base.InitializeApplicationEventsResolver();
ApplicationEventsResolver.Current.AddType();
ApplicationEventsResolver.Current.AddType();
+ //We need to remove these types because we've obsoleted them and we don't want them executing:
+ ApplicationEventsResolver.Current.RemoveType();
}
///
@@ -169,6 +172,14 @@ namespace Umbraco.Web
protected override void InitializeResolvers()
{
base.InitializeResolvers();
+
+ //We are going to manually remove a few cache refreshers here because we've obsoleted them and we don't want them
+ // to be registered more than once
+ CacheRefreshersResolver.Current.RemoveType();
+ CacheRefreshersResolver.Current.RemoveType();
+ CacheRefreshersResolver.Current.RemoveType();
+ CacheRefreshersResolver.Current.RemoveType();
+ CacheRefreshersResolver.Current.RemoveType();
SurfaceControllerResolver.Current = new SurfaceControllerResolver(
PluginManager.Current.ResolveSurfaceControllers());
diff --git a/src/Umbraco.Web/WebServices/SaveFileController.cs b/src/Umbraco.Web/WebServices/SaveFileController.cs
index 10ad9f8af5..91c6c6fc8e 100644
--- a/src/Umbraco.Web/WebServices/SaveFileController.cs
+++ b/src/Umbraco.Web/WebServices/SaveFileController.cs
@@ -112,7 +112,7 @@ namespace Umbraco.Web.WebServices
if (UmbracoSettings.UseDistributedCalls)
dispatcher.Refresh(new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"), t.Id);
else
- template.ClearCachedTemplate(t.Id);
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(t.Id);
return Success(ui.Text("speechBubbles", "templateSavedText"), ui.Text("speechBubbles", "templateSavedHeader"));
}
diff --git a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs b/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
index 3e991fafc4..b29e7f951c 100644
--- a/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
+++ b/src/Umbraco.Web/umbraco.presentation/LibraryCacheRefresher.cs
@@ -1,3 +1,4 @@
+using System;
using umbraco.businesslogic;
using umbraco.cms.businesslogic;
using umbraco.cms.businesslogic.media;
@@ -6,54 +7,10 @@ using umbraco.interfaces;
namespace umbraco
{
- ///
- /// Special class made to listen to save events on objects where umbraco.library caches some of their objects
- ///
- public class LibraryCacheRefresher : IApplicationStartupHandler
+
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.LibraryCacheRefresher instead")]
+ public class LibraryCacheRefresher : Umbraco.Web.Cache.LibraryCacheRefresher
{
- public LibraryCacheRefresher()
- {
- if (UmbracoSettings.UmbracoLibraryCacheDuration > 0)
- {
- Member.AfterSave += new Member.SaveEventHandler(Member_AfterSave);
- Member.BeforeDelete += new Member.DeleteEventHandler(Member_BeforeDelete);
- Media.AfterSave += new Media.SaveEventHandler(Media_AfterSave);
- Media.BeforeDelete += new Media.DeleteEventHandler(Media_BeforeDelete);
- }
-
- // now handled directly by the IRoutesCache implementation
- //content.AfterUpdateDocumentCache += new content.DocumentCacheEventHandler(content_AfterUpdateDocumentCache);
- //content.AfterRefreshContent += new content.RefreshContentEventHandler(content_AfterRefreshContent);
- }
-
- //void content_AfterRefreshContent(Document sender, RefreshContentEventArgs e)
- //{
- // library.ClearNiceUrlCache();
- //}
-
- //void content_AfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)
- //{
- // library.ClearNiceUrlCache();
- //}
-
- void Member_BeforeDelete(Member sender, DeleteEventArgs e)
- {
- library.ClearLibraryCacheForMember(sender.Id);
- }
-
- void Media_BeforeDelete(Media sender, DeleteEventArgs e)
- {
- library.ClearLibraryCacheForMedia(sender.Id);
- }
-
- void Media_AfterSave(Media sender, SaveEventArgs e)
- {
- library.ClearLibraryCacheForMedia(sender.Id);
- }
-
- void Member_AfterSave(Member sender, SaveEventArgs e)
- {
- library.ClearLibraryCacheForMember(sender.Id);
- }
+
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs
index 2d45157eb3..85b3911d99 100644
--- a/src/Umbraco.Web/umbraco.presentation/library.cs
+++ b/src/Umbraco.Web/umbraco.presentation/library.cs
@@ -1854,49 +1854,28 @@ namespace umbraco
return new CMSNode(NodeId).Relations;
}
-
-
+ [Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia instead")]
public static void ClearLibraryCacheForMedia(int mediaId)
{
- if (UmbracoSettings.UseDistributedCalls)
- dispatcher.Refresh(
- new Guid("B29286DD-2D40-4DDB-B325-681226589FEC"),
- mediaId);
- else
- ClearLibraryCacheForMediaDo(mediaId);
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(mediaId);
}
+ [Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia with the allServers flag set to false instead")]
public static void ClearLibraryCacheForMediaDo(int mediaId)
{
- Media m = new Media(mediaId);
- if (m.nodeObjectType == Media._objectType)
- {
- foreach (string id in m.Path.Split(','))
- {
- Cache.ClearCacheByKeySearch(String.Format("UL_{0}_{1}_True", GETMEDIA_CACHE_KEY, id));
-
- // Also clear calls that only query this specific item!
- if (id == m.Id.ToString())
- Cache.ClearCacheByKeySearch(String.Format("UL_{0}_{1}", GETMEDIA_CACHE_KEY, id));
-
- }
- }
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMedia(mediaId, false);
}
+ [Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember instead")]
public static void ClearLibraryCacheForMember(int mediaId)
{
- if (UmbracoSettings.UseDistributedCalls)
- dispatcher.Refresh(
- new Guid("E285DF34-ACDC-4226-AE32-C0CB5CF388DA"),
- mediaId);
- else
- ClearLibraryCacheForMemberDo(mediaId);
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(mediaId);
}
-
+ [Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember with the allServers flag set to false instead")]
public static void ClearLibraryCacheForMemberDo(int memberId)
{
- Cache.ClearCacheByKeySearch(String.Format("UL_{0}_{1}", GETMEMBER_CACHE_KEY, memberId));
+ ApplicationContext.Current.ApplicationCache.ClearLibraryCacheForMember(memberId, false);
}
///
diff --git a/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs b/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs
index ceec535bb1..fc8bee701a 100644
--- a/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs
+++ b/src/Umbraco.Web/umbraco.presentation/macroCacheRefresh.cs
@@ -3,47 +3,9 @@ using umbraco.interfaces;
namespace umbraco
{
- public class macroCacheRefresh : ICacheRefresher
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.MacroCacheRefresher instead")]
+ public class macroCacheRefresh : Umbraco.Web.Cache.MacroCacheRefresher
{
- #region ICacheRefresher Members
- public string Name
- {
- get
- {
- // TODO: Add templateCacheRefresh.Name getter implementation
- return "Macro cache refresher";
- }
- }
-
- public Guid UniqueIdentifier
- {
- get
- {
- // TODO: Add templateCacheRefresh.UniqueIdentifier getter implementation
- return new Guid("7B1E683C-5F34-43dd-803D-9699EA1E98CA");
- }
- }
-
- public void RefreshAll()
- {
- }
-
- public void Refresh(Guid Id)
- {
- // Doesn't do anything
- }
-
- void ICacheRefresher.Refresh(int Id)
- {
- macro.GetMacro(Id).removeFromCache();
- }
-
- void ICacheRefresher.Remove(int Id)
- {
- macro.GetMacro(Id).removeFromCache();
- }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/template.cs b/src/Umbraco.Web/umbraco.presentation/template.cs
index 45b034d8b8..57c40570b6 100644
--- a/src/Umbraco.Web/umbraco.presentation/template.cs
+++ b/src/Umbraco.Web/umbraco.presentation/template.cs
@@ -9,7 +9,8 @@ using System.Data;
using System.Web.UI;
using System.Collections;
using System.Collections.Generic;
-
+using Umbraco.Core;
+using Umbraco.Web;
using umbraco.DataLayer;
using umbraco.BusinessLogic;
using umbraco.IO;
@@ -24,15 +25,19 @@ namespace umbraco
public class template
{
#region private variables
- StringBuilder templateOutput = new StringBuilder();
+
+ readonly StringBuilder _templateOutput = new StringBuilder();
// Cache
- static System.Web.Caching.Cache templateCache = System.Web.HttpRuntime.Cache;
+ //static System.Web.Caching.Cache templateCache = System.Web.HttpRuntime.Cache;
private string _templateDesign = "";
int _masterTemplate = -1;
private string _templateName = "";
private string _templateAlias = "";
+
+ private const string CacheKey = "template";
+
#endregion
#region public properties
@@ -40,11 +45,11 @@ namespace umbraco
{
set
{
- templateOutput.Append(value);
+ _templateOutput.Append(value);
}
get
{
- return templateOutput.ToString();
+ return _templateOutput.ToString();
}
}
@@ -125,7 +130,7 @@ namespace umbraco
if (System.Web.HttpContext.Current.Items["macrosAdded"] == null)
System.Web.HttpContext.Current.Items.Add("macrosAdded", 0);
- StringBuilder tempOutput = templateOutput;
+ StringBuilder tempOutput = _templateOutput;
Control pageLayout = new Control();
Control pageHeader = new Control();
@@ -135,8 +140,8 @@ namespace umbraco
System.Web.UI.HtmlControls.HtmlHead pageAspNetHead = new System.Web.UI.HtmlControls.HtmlHead();
// Find header and footer of page if there is an aspnet-form on page
- if (templateOutput.ToString().ToLower().IndexOf("") > 0 ||
- templateOutput.ToString().ToLower().IndexOf("") > 0)
+ if (_templateOutput.ToString().ToLower().IndexOf("") > 0 ||
+ _templateOutput.ToString().ToLower().IndexOf("") > 0)
{
pageForm.Attributes.Add("method", "post");
pageForm.Attributes.Add("action", Convert.ToString(System.Web.HttpContext.Current.Items["VirtualUrl"]));
@@ -150,7 +155,7 @@ namespace umbraco
if (aspnetFormTagBegin == -1)
{
aspnetFormTagBegin =
- templateOutput.ToString().ToLower().IndexOf("");
+ _templateOutput.ToString().ToLower().IndexOf("");
aspnetFormTagLength = 42;
}
else
@@ -394,7 +399,7 @@ namespace umbraco
// First parse for known umbraco tags
// - macros
// - print item from page, level, or recursive
- MatchCollection tags = Regex.Matches(templateOutput.ToString(), "<\\?UMBRACO_MACRO[^>]*/>|<\\?UMBRACO_GETITEM[^>]*/>|<\\?(?[\\S]*)[^>]*/>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
+ MatchCollection tags = Regex.Matches(_templateOutput.ToString(), "<\\?UMBRACO_MACRO[^>]*/>|<\\?UMBRACO_GETITEM[^>]*/>|<\\?(?[\\S]*)[^>]*/>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match tag in tags)
{
@@ -407,7 +412,7 @@ namespace umbraco
if (macroID != "")
{
macro tempMacro = getMacro(macroID);
- templateOutput.Replace(tag.Value.ToString(), tempMacro.MacroContent.ToString());
+ _templateOutput.Replace(tag.Value.ToString(), tempMacro.MacroContent.ToString());
}
}
else
@@ -425,12 +430,12 @@ namespace umbraco
if (Convert.ToInt32(macroID) > 0)
{
macro tempContentMacro = getMacro(macroID);
- templateOutput.Replace(tag.Value.ToString(), tempContentMacro.MacroContent.ToString());
+ _templateOutput.Replace(tag.Value.ToString(), tempContentMacro.MacroContent.ToString());
}
}
- templateOutput.Replace(tag.Value.ToString(), tempElementContent);
+ _templateOutput.Replace(tag.Value.ToString(), tempElementContent);
}
catch (Exception e)
{
@@ -480,53 +485,53 @@ namespace umbraco
public static string GetMasterPageName(int templateID, string templateFolder)
{
- template t = (template)templateCache["template" + templateID];
- if (t == null)
- t = new template(templateID);
-
- if (t != null)
- if (!string.IsNullOrEmpty(templateFolder))
- return t.AlternateMasterPageFile(templateFolder);
- else
- return t.MasterPageFile;
- else
- throw new ArgumentException(String.Format("Template with id '{0}' not found", templateID));
+ var t = new template(templateID);
+
+ return !string.IsNullOrEmpty(templateFolder)
+ ? t.AlternateMasterPageFile(templateFolder)
+ : t.MasterPageFile;
}
public template(int templateID)
{
- if (templateCache["template" + templateID.ToString()] != null)
- {
- template t = (template)templateCache["template" + templateID];
- this._masterTemplate = t._masterTemplate;
- this._templateAlias = t._templateAlias;
- this._templateDesign = t._templateDesign;
- this._masterTemplate = t._masterTemplate;
- this._templateName = t._templateName;
- }
- else
- {
- using (IRecordsReader templateData = SqlHelper.ExecuteReader("select nodeId, alias, master, text, design from cmsTemplate inner join umbracoNode node on node.id = cmsTemplate.nodeId where nodeId = @templateID", SqlHelper.CreateParameter("@templateID", templateID)))
- {
- if (templateData.Read())
- {
- // Get template master and replace content where the template
- if (!templateData.IsNull("master"))
- _masterTemplate = templateData.GetInt("master");
- if (!templateData.IsNull("alias"))
- _templateAlias = templateData.GetString("alias");
- if (!templateData.IsNull("text"))
- _templateName = templateData.GetString("text");
- if (!templateData.IsNull("design"))
- _templateDesign = templateData.GetString("design");
- templateData.Close();
- templateCache.Insert("template" + templateID.ToString(), this);
- }
- }
- }
+ var tId = templateID;
+
+ var t = ApplicationContext.Current.ApplicationCache.GetCacheItem(
+ string.Format("{0}{1}", CacheKey, tId), () =>
+ {
+ using (var templateData = SqlHelper.ExecuteReader("select nodeId, alias, master, text, design from cmsTemplate inner join umbracoNode node on node.id = cmsTemplate.nodeId where nodeId = @templateID", SqlHelper.CreateParameter("@templateID", templateID)))
+ {
+ if (templateData.Read())
+ {
+ // Get template master and replace content where the template
+ if (!templateData.IsNull("master"))
+ _masterTemplate = templateData.GetInt("master");
+ if (!templateData.IsNull("alias"))
+ _templateAlias = templateData.GetString("alias");
+ if (!templateData.IsNull("text"))
+ _templateName = templateData.GetString("text");
+ if (!templateData.IsNull("design"))
+ _templateDesign = templateData.GetString("design");
+ }
+ }
+ return this;
+ });
+
+ if (t == null)
+ throw new InvalidOperationException("Could not find a tempalte with id " + templateID);
+
+ this._masterTemplate = t._masterTemplate;
+ this._templateAlias = t._templateAlias;
+ this._templateDesign = t._templateDesign;
+ this._masterTemplate = t._masterTemplate;
+ this._templateName = t._templateName;
+
// Only check for master on legacy templates - can show error when using master pages.
- if(!UmbracoSettings.UseAspNetMasterPages)
- checkForMaster(templateID);
+ if (!UmbracoSettings.UseAspNetMasterPages)
+ {
+ checkForMaster(tId);
+ }
+
}
private void checkForMaster(int templateID) {
@@ -535,12 +540,12 @@ namespace umbraco
template masterTemplateDesign = new template(_masterTemplate);
if (masterTemplateDesign.TemplateContent.IndexOf("") > -1
|| masterTemplateDesign.TemplateContent.IndexOf("") > -1) {
- templateOutput.Append(
+ _templateOutput.Append(
masterTemplateDesign.TemplateContent.Replace("",
_templateDesign).Replace("", _templateDesign)
);
} else
- templateOutput.Append(_templateDesign);
+ _templateOutput.Append(_templateDesign);
} else {
if (_masterTemplate == templateID)
{
@@ -548,73 +553,30 @@ namespace umbraco
string templateName = (t != null) ? t.Text : string.Format("'Template with id: '{0}", templateID);
System.Web.HttpContext.Current.Trace.Warn("template",
String.Format("Master template is the same as the current template. It would cause an endless loop! Make sure that the current template '{0}' has another Master Template than itself. You can change this in the template editor under 'Settings'", templateName));
- templateOutput.Append(_templateDesign);
+ _templateOutput.Append(_templateDesign);
}
}
}
+ [Obsolete("Use ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate instead")]
public static void ClearCachedTemplate(int templateID)
{
- if (templateCache["template" + templateID.ToString()] != null)
- templateCache.Remove("template" + templateID.ToString());
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(templateID);
}
public template(String templateContent)
{
- templateOutput.Append(templateContent);
+ _templateOutput.Append(templateContent);
_masterTemplate = 0;
}
#endregion
}
- public class templateCacheRefresh : interfaces.ICacheRefresher
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.TemplateCacheRefresher instead")]
+ public class templateCacheRefresh : Umbraco.Web.Cache.TemplateCacheRefresher
{
- #region ICacheRefresher Members
-
- public string Name
- {
- get
- {
- // TODO: Add templateCacheRefresh.Name getter implementation
- return "Template cache refresher";
- }
- }
-
- public Guid UniqueIdentifier
- {
- get
- {
- // TODO: Add templateCacheRefresh.UniqueIdentifier getter implementation
- return new Guid("DD12B6A0-14B9-46e8-8800-C154F74047C8");
- }
- }
-
- public void RefreshAll()
- {
- // Doesn't do anything
- }
-
- public void Refresh(Guid Id)
- {
- // Doesn't do anything
- }
-
- void umbraco.interfaces.ICacheRefresher.Refresh(int Id)
- {
- template.ClearCachedTemplate(Id);
- }
-
- //PPH remove tamplete from cache
- public void Remove(int Id)
- {
-
- template.ClearCachedTemplate(Id);
-
- }
-
- #endregion
-
+
}
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/CacheRefresher.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/CacheRefresher.cs
index 1447aafa9b..9c79e1f7c1 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/CacheRefresher.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/CacheRefresher.cs
@@ -1,44 +1,29 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version: 1.1.4322.2032
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
+using Umbraco.Core.IO;
-//
-// This source code was auto-generated by wsdl, Version=1.1.4322.2032.
-//
-using System.Diagnostics;
-using System.Xml.Serialization;
-using System;
-using System.Web.Services.Protocols;
-using System.ComponentModel;
-using System.Web.Services;
-using umbraco.IO;
-
-namespace umbraco.presentation.cache {
+namespace umbraco.presentation.cache
+{
///
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "CacheRefresherSoap", Namespace = "http://umbraco.org/webservices/")]
- public class CacheRefresher : System.Web.Services.Protocols.SoapHttpClientProtocol {
+ public class CacheRefresher : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
///
- public CacheRefresher() {
+ public CacheRefresher()
+ {
// only set the url if the httpcontext is present, else it's set by the cache dispatcher methods (when using distributed calls)
if (System.Web.HttpContext.Current != null)
- this.Url = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + IOHelper.ResolveUrl(SystemDirectories.Webservices) + "/cacheRefresher.asmx";
-
+ this.Url = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + IOHelper.ResolveUrl(SystemDirectories.WebServices) + "/cacheRefresher.asmx";
+
}
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshAll", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
- public void RefreshAll(System.Guid uniqueIdentifier, string Login, string Password) {
+ public void RefreshAll(System.Guid uniqueIdentifier, string Login, string Password)
+ {
this.Invoke("RefreshAll", new object[] {
uniqueIdentifier,
Login,
@@ -46,7 +31,8 @@ namespace umbraco.presentation.cache {
}
///
- public System.IAsyncResult BeginRefreshAll(System.Guid uniqueIdentifier, string Login, string Password, System.AsyncCallback callback, object asyncState) {
+ public System.IAsyncResult BeginRefreshAll(System.Guid uniqueIdentifier, string Login, string Password, System.AsyncCallback callback, object asyncState)
+ {
return this.BeginInvoke("RefreshAll", new object[] {
uniqueIdentifier,
Login,
@@ -54,13 +40,15 @@ namespace umbraco.presentation.cache {
}
///
- public void EndRefreshAll(System.IAsyncResult asyncResult) {
+ public void EndRefreshAll(System.IAsyncResult asyncResult)
+ {
this.EndInvoke(asyncResult);
}
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshByGuid", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
- public void RefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password) {
+ public void RefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password)
+ {
this.Invoke("RefreshByGuid", new object[] {
uniqueIdentifier,
Id,
@@ -69,7 +57,8 @@ namespace umbraco.presentation.cache {
}
///
- public System.IAsyncResult BeginRefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password, System.AsyncCallback callback, object asyncState) {
+ public System.IAsyncResult BeginRefreshByGuid(System.Guid uniqueIdentifier, System.Guid Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
+ {
return this.BeginInvoke("RefreshByGuid", new object[] {
uniqueIdentifier,
Id,
@@ -78,13 +67,15 @@ namespace umbraco.presentation.cache {
}
///
- public void EndRefreshByGuid(System.IAsyncResult asyncResult) {
+ public void EndRefreshByGuid(System.IAsyncResult asyncResult)
+ {
this.EndInvoke(asyncResult);
}
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RefreshById", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
- public void RefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password) {
+ public void RefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password)
+ {
this.Invoke("RefreshById", new object[] {
uniqueIdentifier,
Id,
@@ -93,7 +84,8 @@ namespace umbraco.presentation.cache {
}
///
- public System.IAsyncResult BeginRefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState) {
+ public System.IAsyncResult BeginRefreshById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
+ {
return this.BeginInvoke("RefreshById", new object[] {
uniqueIdentifier,
Id,
@@ -102,13 +94,15 @@ namespace umbraco.presentation.cache {
}
///
- public void EndRefreshById(System.IAsyncResult asyncResult) {
+ public void EndRefreshById(System.IAsyncResult asyncResult)
+ {
this.EndInvoke(asyncResult);
}
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/RemoveById", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
- public void RemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password) {
+ public void RemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password)
+ {
this.Invoke("RemoveById", new object[] {
uniqueIdentifier,
Id,
@@ -117,7 +111,8 @@ namespace umbraco.presentation.cache {
}
///
- public System.IAsyncResult BeginRemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState) {
+ public System.IAsyncResult BeginRemoveById(System.Guid uniqueIdentifier, int Id, string Login, string Password, System.AsyncCallback callback, object asyncState)
+ {
return this.BeginInvoke("RemoveById", new object[] {
uniqueIdentifier,
Id,
@@ -126,13 +121,15 @@ namespace umbraco.presentation.cache {
}
///
- public void EndRemoveById(System.IAsyncResult asyncResult) {
+ public void EndRemoveById(System.IAsyncResult asyncResult)
+ {
this.EndInvoke(asyncResult);
}
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://umbraco.org/webservices/GetRefreshers", RequestNamespace = "http://umbraco.org/webservices/", ResponseNamespace = "http://umbraco.org/webservices/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
- public System.Xml.XmlNode GetRefreshers(string Login, string Password) {
+ public System.Xml.XmlNode GetRefreshers(string Login, string Password)
+ {
object[] results = this.Invoke("GetRefreshers", new object[] {
Login,
Password});
@@ -140,14 +137,16 @@ namespace umbraco.presentation.cache {
}
///
- public System.IAsyncResult BeginGetRefreshers(string Login, string Password, System.AsyncCallback callback, object asyncState) {
+ public System.IAsyncResult BeginGetRefreshers(string Login, string Password, System.AsyncCallback callback, object asyncState)
+ {
return this.BeginInvoke("GetRefreshers", new object[] {
Login,
Password}, callback, asyncState);
}
///
- public System.Xml.XmlNode EndGetRefreshers(System.IAsyncResult asyncResult) {
+ public System.Xml.XmlNode EndGetRefreshers(System.IAsyncResult asyncResult)
+ {
object[] results = this.EndInvoke(asyncResult);
return ((System.Xml.XmlNode)(results[0]));
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/dispatcher.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/dispatcher.cs
index 0f95aace02..bc2ed8fb56 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/dispatcher.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/dispatcher.cs
@@ -3,12 +3,13 @@ using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Threading;
+using System.Web.Services.Protocols;
using System.Xml;
using Umbraco.Core;
+using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using umbraco.BusinessLogic;
using umbraco.interfaces;
-using umbraco.IO;
namespace umbraco.presentation.cache
{
@@ -26,14 +27,14 @@ namespace umbraco.presentation.cache
///
public class dispatcher
{
- private static readonly string _login = User.GetUser(UmbracoSettings.DistributedCallUser).LoginName;
- private static readonly string _password = User.GetUser(UmbracoSettings.DistributedCallUser).GetPassword();
- private static readonly string _webServicesUrl;
+ private static readonly string Login = User.GetUser(UmbracoSettings.DistributedCallUser).LoginName;
+ private static readonly string Password = User.GetUser(UmbracoSettings.DistributedCallUser).GetPassword();
+ private static readonly string WebServicesUrl;
static dispatcher()
{
- _webServicesUrl = IOHelper.ResolveUrl(SystemDirectories.Webservices);
+ WebServicesUrl = IOHelper.ResolveUrl(SystemDirectories.WebServices);
}
///
@@ -41,10 +42,10 @@ namespace umbraco.presentation.cache
/// using the specified ICacheRefresher with the guid factoryGuid.
///
/// The unique identifier of the ICacheRefresher used to refresh the node.
- /// The id of the node.
- public static void Refresh(Guid factoryGuid, int Id)
+ /// The id of the node.
+ public static void Refresh(Guid factoryGuid, int id)
{
- InvokeDispatchMethod(DispatchType.RefreshByNumericId, factoryGuid, Id, Guid.Empty);
+ InvokeDispatchMethod(DispatchType.RefreshByNumericId, factoryGuid, id, Guid.Empty);
}
///
@@ -52,10 +53,10 @@ namespace umbraco.presentation.cache
/// using the specified ICacheRefresher with the guid factoryGuid.
///
/// The unique identifier of the ICacheRefresher used to refresh the node.
- /// The guid of the node.
- public static void Refresh(Guid factoryGuid, Guid Id)
+ /// The guid of the node.
+ public static void Refresh(Guid factoryGuid, Guid id)
{
- InvokeDispatchMethod(DispatchType.RefreshByGuid, factoryGuid, 0, Id);
+ InvokeDispatchMethod(DispatchType.RefreshByGuid, factoryGuid, 0, id);
}
///
@@ -73,10 +74,10 @@ namespace umbraco.presentation.cache
/// using the specified ICacheRefresher with the guid factoryGuid.
///
/// The unique identifier.
- /// The id.
- public static void Remove(Guid factoryGuid, int Id)
+ /// The id.
+ public static void Remove(Guid factoryGuid, int id)
{
- InvokeDispatchMethod(DispatchType.RemoveById, factoryGuid, Id, Guid.Empty);
+ InvokeDispatchMethod(DispatchType.RemoveById, factoryGuid, id, Guid.Empty);
}
///
@@ -107,20 +108,20 @@ namespace umbraco.presentation.cache
switch (dispatchType)
{
case DispatchType.RefreshAll:
- asyncResultsList.Add(cacheRefresher.BeginRefreshAll(factoryGuid, _login, _password, null,
+ asyncResultsList.Add(cacheRefresher.BeginRefreshAll(factoryGuid, Login, Password, null,
null));
break;
case DispatchType.RefreshByGuid:
- asyncResultsList.Add(cacheRefresher.BeginRefreshByGuid(factoryGuid, guidId, _login,
- _password, null, null));
+ asyncResultsList.Add(cacheRefresher.BeginRefreshByGuid(factoryGuid, guidId, Login,
+ Password, null, null));
break;
case DispatchType.RefreshByNumericId:
- asyncResultsList.Add(cacheRefresher.BeginRefreshById(factoryGuid, numericId, _login,
- _password, null, null));
+ asyncResultsList.Add(cacheRefresher.BeginRefreshById(factoryGuid, numericId, Login,
+ Password, null, null));
break;
case DispatchType.RemoveById:
- asyncResultsList.Add(cacheRefresher.BeginRemoveById(factoryGuid, numericId, _login,
- _password, null, null));
+ asyncResultsList.Add(cacheRefresher.BeginRemoveById(factoryGuid, numericId, Login,
+ Password, null, null));
break;
}
}
@@ -205,16 +206,16 @@ namespace umbraco.presentation.cache
///
/// The CacheRefresher.
/// The XmlNode.
- private static void SetWebServiceUrlFromNode(CacheRefresher cr, XmlNode n)
+ private static void SetWebServiceUrlFromNode(WebClientProtocol cr, XmlNode n)
{
string protocol = GlobalSettings.UseSSL ? "https" : "http";
if (n.Attributes.GetNamedItem("forceProtocol") != null && !String.IsNullOrEmpty(n.Attributes.GetNamedItem("forceProtocol").Value))
protocol = n.Attributes.GetNamedItem("forceProtocol").Value;
- string domain = xmlHelper.GetNodeValue(n);
+ string domain = XmlHelper.GetNodeValue(n);
if (n.Attributes.GetNamedItem("forcePortnumber") != null && !String.IsNullOrEmpty(n.Attributes.GetNamedItem("forcePortnumber").Value))
domain += string.Format(":{0}", n.Attributes.GetNamedItem("forcePortnumber").Value);
- cr.Url = string.Format("{0}://{1}{2}/cacheRefresher.asmx", protocol, domain, _webServicesUrl);
+ cr.Url = string.Format("{0}://{1}{2}/cacheRefresher.asmx", protocol, domain, WebServicesUrl);
}
private static string GetFactoryObjectName(Guid uniqueIdentifier)
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/libraryRefreshers.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/libraryRefreshers.cs
index 6dc0440d74..5db5f04f16 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/libraryRefreshers.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/libraryRefreshers.cs
@@ -2,78 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
+using Umbraco.Core;
+using Umbraco.Web;
namespace umbraco.presentation.cache
{
- public class MediaLibraryRefreshers : interfaces.ICacheRefresher
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.MediaLibraryRefreshers instead")]
+ public class MediaLibraryRefreshers : Umbraco.Web.Cache.MediaLibraryRefreshers
{
- public MediaLibraryRefreshers()
- {
-
- }
-
- public Guid UniqueIdentifier
- {
- get { return new Guid("B29286DD-2D40-4DDB-B325-681226589FEC"); }
- }
-
- public string Name
- {
- get { return "Clears Media Cache from umbraco.library"; }
- }
-
- public void RefreshAll()
- {
- }
-
- public void Refresh(int Id)
- {
- library.ClearLibraryCacheForMediaDo(Id);
- }
-
- public void Remove(int Id)
- {
- }
-
- public void Refresh(Guid Id)
- {
- }
-
+
}
- public class MemberLibraryRefreshers : interfaces.ICacheRefresher
+ [Obsolete("This class is no longer used, use Umbraco.Web.Cache.MemberLibraryRefreshers instead")]
+ public class MemberLibraryRefreshers : Umbraco.Web.Cache.MemberLibraryRefreshers
{
- public MemberLibraryRefreshers()
- {
-
- }
-
- public Guid UniqueIdentifier
- {
- get { return new Guid("E285DF34-ACDC-4226-AE32-C0CB5CF388DA"); }
- }
-
- public string Name
- {
- get { return "Clears Member Cache from umbraco.library"; }
- }
-
- public void RefreshAll()
- {
- }
-
- public void Refresh(int Id)
- {
- library.ClearLibraryCacheForMemberDo(Id);
- }
-
- public void Remove(int Id)
- {
- }
-
- public void Refresh(Guid Id)
- {
- }
-
+
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/pageRefresher.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/pageRefresher.cs
index 60b01b3938..7192a4ae67 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/cache/pageRefresher.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/cache/pageRefresher.cs
@@ -1,4 +1,5 @@
using System;
+using Umbraco.Web.Cache;
namespace umbraco.presentation.cache
{
@@ -11,76 +12,8 @@ namespace umbraco.presentation.cache
///
/// pageRefresger inherits from interfaces.ICacheRefresher.
///
- public class pageRefresher : interfaces.ICacheRefresher
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public pageRefresher()
- {
- //
- // TODO: Add constructor logic here
- //
- }
- #region ICacheRefresher Members
-
- ///
- /// Gets the unique identifier of the CacheRefresher.
- ///
- /// The unique identifier.
- public Guid UniqueIdentifier
- {
- get
- {
- // TODO: Add pageRefresher.uniqueIdentifier getter implementation
- return new Guid("27AB3022-3DFA-47b6-9119-5945BC88FD66");
- }
- }
-
- ///
- /// Gets the name of the CacheRefresher
- ///
- /// The name.
- public string Name
- {
- get {return "Page Refresher (umbraco.library wrapper)";}
- }
-
- ///
- /// Refreshes all nodes in umbraco.
- ///
- public void RefreshAll()
- {
- // library.RePublishNodesDotNet(-1, true);
- content.Instance.RefreshContentFromDatabaseAsync();
- }
-
- ///
- /// Not used with content.
- ///
- /// The id.
- public void Refresh(Guid Id)
- {
- // Not used when pages
- }
-
- ///
- /// Refreshes the cache for the node with specified id
- ///
- /// The id.
- public void Refresh(int Id) {
- content.Instance.UpdateDocumentCache(Id);
- }
-
-
- ///
- /// Removes the node with the specified id from the cache
- ///
- /// The id.
- public void Remove(int Id) {
- content.Instance.ClearDocumentCache(Id);
- }
-
- #endregion
+ [Obsolete("This class is no longer in use, use Umbraco.Web.Cache.PageCacheRefresher instead")]
+ public class pageRefresher : PageCacheRefresher
+ {
}
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
index 9d34946b21..2ff1946502 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/codeEditorSave.asmx.cs
@@ -11,7 +11,9 @@ using System.Web.Services;
using System.Web.UI;
using System.Xml;
using System.Xml.Xsl;
+using Umbraco.Core;
using Umbraco.Core.IO;
+using Umbraco.Web;
using umbraco.BasePages;
using umbraco.cms.businesslogic.macro;
using umbraco.cms.businesslogic.template;
@@ -469,7 +471,7 @@ namespace umbraco.presentation.webservices
if (UmbracoSettings.UseDistributedCalls)
dispatcher.Refresh(new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"), _template.Id);
else
- template.ClearCachedTemplate(_template.Id);
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(_template.Id);
}
return retVal;
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs
index ac154c71f6..eff41f4668 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/legacyAjaxCalls.asmx.cs
@@ -16,7 +16,9 @@ using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Net;
using System.Web.UI;
+using Umbraco.Core;
using Umbraco.Core.IO;
+using Umbraco.Web;
using umbraco.businesslogic.Exceptions;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.media;
@@ -431,7 +433,7 @@ namespace umbraco.presentation.webservices
new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"),
tp.Id);
else
- template.ClearCachedTemplate(tp.Id);
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(tp.Id);
return retVal;
diff --git a/src/umbraco.webservices/templates/templateService.cs b/src/umbraco.webservices/templates/templateService.cs
index 7b5fbe524f..2a093cc1dc 100644
--- a/src/umbraco.webservices/templates/templateService.cs
+++ b/src/umbraco.webservices/templates/templateService.cs
@@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.Services;
+using Umbraco.Core;
+using Umbraco.Web;
namespace umbraco.webservices.templates
{
@@ -211,7 +213,7 @@ namespace umbraco.webservices.templates
new Guid("dd12b6a0-14b9-46e8-8800-c154f74047c8"),
cachedTemplate.Id);
else
- umbraco.template.ClearCachedTemplate(cachedTemplate.Id);
+ ApplicationContext.Current.ApplicationCache.ClearCacheForTemplate(cachedTemplate.Id);
}
}