removes PublishedSnapshotServiceBase, shrinks interface
This commit is contained in:
@@ -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<NuCacheSettings> config)
|
||||
: base(publishedSnapshotAccessor, variationContextAccessor)
|
||||
{
|
||||
_serviceContext = serviceContext;
|
||||
_publishedContentTypeFactory = publishedContentTypeFactory;
|
||||
_publishedSnapshotAccessor = publishedSnapshotAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_profilingLogger = profilingLogger;
|
||||
_loggerFactory = loggerFactory;
|
||||
_logger = _loggerFactory.CreateLogger<PublishedSnapshotService>();
|
||||
@@ -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<int, Domain>();
|
||||
}
|
||||
}
|
||||
|
||||
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<string> errors)
|
||||
public bool EnsureEnvironment(out IEnumerable<string> 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
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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<T>(ContentStore store, ContentTypeCacheRefresher.JsonPayload[] payloads, Action<List<int>, List<int>, List<int>, List<int>> 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
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Rebuild(
|
||||
public void Rebuild(
|
||||
int groupSize = 5000,
|
||||
IReadOnlyCollection<int> contentTypeIds = null,
|
||||
IReadOnlyCollection<int> 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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user