diff --git a/src/Umbraco.Core/PublishedCache/IPublishedSnapshotService.cs b/src/Umbraco.Core/PublishedCache/IPublishedSnapshotService.cs
index af8f72ce6d..840b64c541 100644
--- a/src/Umbraco.Core/PublishedCache/IPublishedSnapshotService.cs
+++ b/src/Umbraco.Core/PublishedCache/IPublishedSnapshotService.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Umbraco.Core.Models.Membership;
using Umbraco.Web.Cache;
namespace Umbraco.Web.PublishedCache
@@ -23,11 +22,6 @@ namespace Umbraco.Web.PublishedCache
*
*/
- ///
- /// Gets the published snapshot accessor.
- ///
- IPublishedSnapshotAccessor PublishedSnapshotAccessor { get; }
-
///
/// Creates a published snapshot.
///
diff --git a/src/Umbraco.Core/PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Core/PublishedCache/PublishedSnapshotServiceBase.cs
deleted file mode 100644
index f33eb61e8f..0000000000
--- a/src/Umbraco.Core/PublishedCache/PublishedSnapshotServiceBase.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Umbraco.Core.Models.Membership;
-using Umbraco.Core.Models.PublishedContent;
-using Umbraco.Web.Cache;
-
-namespace Umbraco.Web.PublishedCache
-{
- // TODO: This base class probably shouldn't exist
- public abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService
- {
- ///
- /// Initializes a new instance of the class.
- ///
- protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
- {
- PublishedSnapshotAccessor = publishedSnapshotAccessor;
- VariationContextAccessor = variationContextAccessor;
- }
-
- ///
- public IPublishedSnapshotAccessor PublishedSnapshotAccessor { get; }
-
- ///
- /// Gets the
- ///
- public IVariationContextAccessor VariationContextAccessor { get; }
-
- // note: NOT setting _publishedSnapshotAccessor.PublishedSnapshot here because it is the
- // responsibility of the caller to manage what the 'current' facade is
-
- ///
- public abstract IPublishedSnapshot CreatePublishedSnapshot(string previewToken);
-
- protected IPublishedSnapshot CurrentPublishedSnapshot => PublishedSnapshotAccessor.PublishedSnapshot;
-
- ///
- public abstract bool EnsureEnvironment(out IEnumerable errors);
-
- ///
- public abstract void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged);
-
- ///
- public abstract void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged);
-
- ///
- public abstract void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads);
-
- ///
- public abstract void Notify(DataTypeCacheRefresher.JsonPayload[] payloads);
-
- ///
- public abstract void Notify(DomainCacheRefresher.JsonPayload[] payloads);
-
- ///
- public abstract void Rebuild(
- int groupSize = 5000,
- IReadOnlyCollection contentTypeIds = null,
- IReadOnlyCollection mediaTypeIds = null,
- IReadOnlyCollection memberTypeIds = null);
-
- ///
- public virtual void Dispose()
- { }
-
- ///
- public abstract string GetStatus();
-
- ///
- public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html";
-
- ///
- public virtual void Collect()
- {
- }
-
- }
-}
diff --git a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs
index 6225e68ec6..e695517553 100644
--- a/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs
+++ b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs
@@ -14,7 +14,6 @@ using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
-using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Scoping;
@@ -29,10 +28,12 @@ using File = System.IO.File;
namespace Umbraco.Web.PublishedCache.NuCache
{
- internal class PublishedSnapshotService : PublishedSnapshotServiceBase
+ internal class PublishedSnapshotService : IPublishedSnapshotService
{
private readonly ServiceContext _serviceContext;
private readonly IPublishedContentTypeFactory _publishedContentTypeFactory;
+ private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
+ private readonly IVariationContextAccessor _variationContextAccessor;
private readonly IProfilingLogger _profilingLogger;
private readonly IScopeProvider _scopeProvider;
private readonly INuCacheContentService _publishedContentService;
@@ -91,10 +92,11 @@ namespace Umbraco.Web.PublishedCache.NuCache
IHostingEnvironment hostingEnvironment,
IIOHelper ioHelper, // TODO: Remove this, it is only needed for "EnsureEnvironment" which doesn't need to belong to this service
IOptions config)
- : base(publishedSnapshotAccessor, variationContextAccessor)
{
_serviceContext = serviceContext;
_publishedContentTypeFactory = publishedContentTypeFactory;
+ _publishedSnapshotAccessor = publishedSnapshotAccessor;
+ _variationContextAccessor = variationContextAccessor;
_profilingLogger = profilingLogger;
_loggerFactory = loggerFactory;
_logger = _loggerFactory.CreateLogger();
@@ -126,22 +128,24 @@ namespace Umbraco.Web.PublishedCache.NuCache
// figure out whether it can read the databases or it should populate them from sql
_logger.LogInformation("Creating the content store, localContentDbExists? {LocalContentDbExists}", _localContentDbExists);
- _contentStore = new ContentStore(PublishedSnapshotAccessor, VariationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localContentDb);
+ _contentStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localContentDb);
_logger.LogInformation("Creating the media store, localMediaDbExists? {LocalMediaDbExists}", _localMediaDbExists);
- _mediaStore = new ContentStore(PublishedSnapshotAccessor, VariationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localMediaDb);
+ _mediaStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory, _localMediaDb);
}
else
{
_logger.LogInformation("Creating the content store (local db ignored)");
- _contentStore = new ContentStore(PublishedSnapshotAccessor, VariationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
+ _contentStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
_logger.LogInformation("Creating the media store (local db ignored)");
- _mediaStore = new ContentStore(PublishedSnapshotAccessor, VariationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
+ _mediaStore = new ContentStore(_publishedSnapshotAccessor, _variationContextAccessor, _loggerFactory.CreateLogger("ContentStore"), _loggerFactory, _publishedModelFactory);
}
_domainStore = new SnapDictionary();
}
}
+ protected PublishedSnapshot CurrentPublishedSnapshot => (PublishedSnapshot)_publishedSnapshotAccessor.PublishedSnapshot;
+
// NOTE: These aren't used within this object but are made available internally to improve the IdKey lookup performance
// when nucache is enabled.
// TODO: Does this need to be here?
@@ -249,7 +253,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- public override bool EnsureEnvironment(out IEnumerable errors)
+ public bool EnsureEnvironment(out IEnumerable errors)
{
// must have app_data and be able to write files into it
var ok = _ioHelper.TryCreateDirectory(GetLocalFilesPath());
@@ -497,7 +501,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// pure live model factory, if any, locked and refreshed - see ContentTypeCacheRefresher and
// DataTypeCacheRefresher
- public override void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
+ public void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
{
// no cache, trash everything
if (Volatile.Read(ref _isReady) == false)
@@ -516,7 +520,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (draftChanged || publishedChanged)
{
- ((PublishedSnapshot)CurrentPublishedSnapshot)?.Resync();
+ CurrentPublishedSnapshot.Resync();
}
}
@@ -598,7 +602,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
///
- public override void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
+ public void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
{
// no cache, trash everything
if (Volatile.Read(ref _isReady) == false)
@@ -616,7 +620,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (anythingChanged)
{
- ((PublishedSnapshot)CurrentPublishedSnapshot)?.Resync();
+ CurrentPublishedSnapshot.Resync();
}
}
@@ -696,7 +700,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
///
- public override void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
+ public void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
{
// no cache, nothing we can do
if (Volatile.Read(ref _isReady) == false)
@@ -746,7 +750,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- ((PublishedSnapshot)CurrentPublishedSnapshot)?.Resync();
+ CurrentPublishedSnapshot.Resync();
}
private void Notify(ContentStore store, ContentTypeCacheRefresher.JsonPayload[] payloads, Action, List, List, List> action)
@@ -797,7 +801,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- public override void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
+ public void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
{
// no cache, nothing we can do
if (Volatile.Read(ref _isReady) == false)
@@ -838,10 +842,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- ((PublishedSnapshot)CurrentPublishedSnapshot)?.Resync();
+ CurrentPublishedSnapshot.Resync();
}
- public override void Notify(DomainCacheRefresher.JsonPayload[] payloads)
+ public void Notify(DomainCacheRefresher.JsonPayload[] payloads)
{
// no cache, nothing we can do
if (Volatile.Read(ref _isReady) == false)
@@ -1013,7 +1017,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- public override IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
+ public IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
{
EnsureCaches();
@@ -1105,9 +1109,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
return new PublishedSnapshot.PublishedSnapshotElements
{
- ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, Options.Create(_globalSettings), VariationContextAccessor),
- MediaCache = new MediaCache(previewDefault, mediaSnap, VariationContextAccessor),
- MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, memberTypeCache, PublishedSnapshotAccessor, VariationContextAccessor, _entitySerializer, _publishedModelFactory),
+ ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainCache, Options.Create(_globalSettings), _variationContextAccessor),
+ MediaCache = new MediaCache(previewDefault, mediaSnap, _variationContextAccessor),
+ MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, memberTypeCache, _publishedSnapshotAccessor, _variationContextAccessor, _entitySerializer, _publishedModelFactory),
DomainCache = domainCache,
SnapshotCache = snapshotCache,
ElementsCache = elementsCache
@@ -1115,7 +1119,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
///
- public override void Rebuild(
+ public void Rebuild(
int groupSize = 5000,
IReadOnlyCollection contentTypeIds = null,
IReadOnlyCollection mediaTypeIds = null,
@@ -1158,7 +1162,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
}
- public override string GetStatus()
+ public string GetStatus()
{
EnsureCaches();
@@ -1184,7 +1188,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// TODO: This should be async since it's calling into async
- public override void Collect()
+ public void Collect()
{
EnsureCaches();
@@ -1204,5 +1208,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
EnsureCaches();
return _mediaStore;
}
+
+ ///
+ public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html";
+
+ ///
+ public void Dispose()
+ { }
}
}
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
index 5e05e31708..6b8b13cc99 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs
@@ -25,7 +25,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
///
/// Implements a published snapshot service.
///
- internal class XmlPublishedSnapshotService : PublishedSnapshotServiceBase
+ internal class XmlPublishedSnapshotService : IPublishedSnapshotService
{
private readonly XmlStore _xmlStore;
private readonly RoutesCache _routesCache;
@@ -48,13 +48,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Constructors
// used in WebBootManager + tests
- public XmlPublishedSnapshotService(ServiceContext serviceContext,
+ public XmlPublishedSnapshotService(
+ ServiceContext serviceContext,
IPublishedContentTypeFactory publishedContentTypeFactory,
IScopeProvider scopeProvider,
IAppCache requestCache,
- IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
+ IPublishedSnapshotAccessor publishedSnapshotAccessor,
+ IVariationContextAccessor variationContextAccessor,
IUmbracoContextAccessor umbracoContextAccessor,
- IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
+ IDocumentRepository documentRepository,
+ IMediaRepository mediaRepository,
+ IMemberRepository memberRepository,
IDefaultCultureAccessor defaultCultureAccessor,
ILoggerFactory loggerFactory,
GlobalSettings globalSettings,
@@ -63,9 +67,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IShortStringHelper shortStringHelper,
ISiteDomainHelper siteDomainHelper,
IEntityXmlSerializer entitySerializer,
-
MainDom mainDom,
- bool testing = false, bool enableRepositoryEvents = true)
+ bool testing = false,
+ bool enableRepositoryEvents = true)
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache,
publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor,
documentRepository, mediaRepository, memberRepository,
@@ -76,13 +80,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
}
// used in some tests
- internal XmlPublishedSnapshotService(ServiceContext serviceContext,
+ internal XmlPublishedSnapshotService(
+ ServiceContext serviceContext,
IPublishedContentTypeFactory publishedContentTypeFactory,
IScopeProvider scopeProvider,
IAppCache requestCache,
- IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
+ IPublishedSnapshotAccessor publishedSnapshotAccessor,
+ IVariationContextAccessor variationContextAccessor,
IUmbracoContextAccessor umbracoContextAccessor,
- IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
+ IDocumentRepository documentRepository,
+ IMediaRepository mediaRepository,
+ IMemberRepository memberRepository,
IDefaultCultureAccessor defaultCultureAccessor,
ILoggerFactory loggerFactory,
GlobalSettings globalSettings,
@@ -93,8 +101,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
IEntityXmlSerializer entitySerializer,
PublishedContentTypeCache contentTypeCache,
MainDom mainDom,
- bool testing, bool enableRepositoryEvents)
- : base(publishedSnapshotAccessor, variationContextAccessor)
+ bool testing,
+ bool enableRepositoryEvents)
{
_routesCache = new RoutesCache();
_publishedContentTypeFactory = publishedContentTypeFactory;
@@ -120,7 +128,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
_hostingLifetime = hostingLifetime;
}
- public override void Dispose()
+ public void Dispose()
{
_xmlStore.Dispose();
}
@@ -129,7 +137,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Environment
- public override bool EnsureEnvironment(out IEnumerable errors)
+ public bool EnsureEnvironment(out IEnumerable errors)
{
// Test creating/saving/deleting a file in the same location as the content xml file
// NOTE: We cannot modify the xml file directly because a background thread is responsible for
@@ -151,7 +159,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Caches
- public override IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
+ public IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
{
// use _requestCache to store recursive properties lookup, etc. both in content
// and media cache. Life span should be the current request. Or, ideally
@@ -169,6 +177,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#endregion
+ public string StatusUrl => throw new System.NotImplementedException();
+
#region Xml specific
///
@@ -215,12 +225,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
#region Change management
- public override void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
+ public void Notify(ContentCacheRefresher.JsonPayload[] payloads, out bool draftChanged, out bool publishedChanged)
{
_xmlStore.Notify(payloads, out draftChanged, out publishedChanged);
}
- public override void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
+ public void Notify(MediaCacheRefresher.JsonPayload[] payloads, out bool anythingChanged)
{
foreach (var payload in payloads)
PublishedMediaCache.ClearCache(payload.Id);
@@ -228,31 +238,33 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
anythingChanged = true;
}
- public override void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
+ public void Notify(ContentTypeCacheRefresher.JsonPayload[] payloads)
{
_xmlStore.Notify(payloads);
if (payloads.Any(x => x.ItemType == typeof(IContentType).Name))
_routesCache.Clear();
}
- public override void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
+ public void Notify(DataTypeCacheRefresher.JsonPayload[] payloads)
{
_publishedContentTypeFactory.NotifyDataTypeChanges(payloads.Select(x => x.Id).ToArray());
_xmlStore.Notify(payloads);
}
- public override void Notify(DomainCacheRefresher.JsonPayload[] payloads)
+ public void Notify(DomainCacheRefresher.JsonPayload[] payloads)
{
_routesCache.Clear();
}
#endregion
- public override string GetStatus()
+ public string GetStatus()
{
return "Test status";
}
- public override void Rebuild(int groupSize = 5000, IReadOnlyCollection contentTypeIds = null, IReadOnlyCollection mediaTypeIds = null, IReadOnlyCollection memberTypeIds = null) { }
+ public void Rebuild(int groupSize = 5000, IReadOnlyCollection contentTypeIds = null, IReadOnlyCollection mediaTypeIds = null, IReadOnlyCollection memberTypeIds = null) { }
+
+ public void Collect() { }
}
}