Fixes IPublishedShapshot and friends
This commit is contained in:
@@ -98,7 +98,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private CacheValues GetCacheValues(PropertyCacheLevel cacheLevel)
|
||||
{
|
||||
CacheValues cacheValues;
|
||||
PublishedShapshot publishedSnapshot;
|
||||
PublishedSnapshot publishedSnapshot;
|
||||
ICacheProvider cache;
|
||||
switch (cacheLevel)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// elements cache (if we don't want to pollute the elements cache with short-lived
|
||||
// data) depending on settings
|
||||
// for members, always cache in the snapshot cache - never pollute elements cache
|
||||
publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot;
|
||||
publishedSnapshot = (PublishedSnapshot) _publishedSnapshotAccessor.PublishedSnapshot;
|
||||
cache = publishedSnapshot == null
|
||||
? null
|
||||
: ((_isPreviewing == false || PublishedSnapshotService.FullCacheWhenPreviewing) && (_isMember == false)
|
||||
@@ -125,7 +125,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
break;
|
||||
case PropertyCacheLevel.Snapshot:
|
||||
// cache within the snapshot cache
|
||||
publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot;
|
||||
publishedSnapshot = (PublishedSnapshot) _publishedSnapshotAccessor.PublishedSnapshot;
|
||||
cache = publishedSnapshot?.SnapshotCache;
|
||||
cacheValues = GetCacheValues(cache);
|
||||
break;
|
||||
|
||||
@@ -102,10 +102,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// this is for tests purposes
|
||||
// args are: current published snapshot (may be null), previewing, content id - returns: content
|
||||
|
||||
internal static Func<IPublishedShapshot, bool, int, IPublishedContent> GetContentByIdFunc { get; set; }
|
||||
internal static Func<IPublishedSnapshot, bool, int, IPublishedContent> GetContentByIdFunc { get; set; }
|
||||
= (publishedShapshot, previewing, id) => publishedShapshot.Content.GetById(previewing, id);
|
||||
|
||||
internal static Func<IPublishedShapshot, bool, int, IPublishedContent> GetMediaByIdFunc { get; set; }
|
||||
internal static Func<IPublishedSnapshot, bool, int, IPublishedContent> GetMediaByIdFunc { get; set; }
|
||||
= (publishedShapshot, previewing, id) => publishedShapshot.Media.GetById(previewing, id);
|
||||
|
||||
private IPublishedContent GetContentById(bool previewing, int id)
|
||||
@@ -289,7 +289,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// beware what you use that one for - you don't want to cache its result
|
||||
private ICacheProvider GetAppropriateCache()
|
||||
{
|
||||
var publishedSnapshot = (PublishedShapshot)_publishedSnapshotAccessor.PublishedSnapshot;
|
||||
var publishedSnapshot = (PublishedSnapshot)_publishedSnapshotAccessor.PublishedSnapshot;
|
||||
var cache = publishedSnapshot == null
|
||||
? null
|
||||
: ((IsPreviewing == false || PublishedSnapshotService.FullCacheWhenPreviewing) && (ItemType != PublishedItemType.Member)
|
||||
@@ -300,7 +300,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
private ICacheProvider GetCurrentSnapshotCache()
|
||||
{
|
||||
var publishedSnapshot = (PublishedShapshot)_publishedSnapshotAccessor.PublishedSnapshot;
|
||||
var publishedSnapshot = (PublishedSnapshot)_publishedSnapshotAccessor.PublishedSnapshot;
|
||||
return publishedSnapshot?.SnapshotCache;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Umbraco.Core.Cache;
|
||||
namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
// implements published snapshot
|
||||
internal class PublishedShapshot : IPublishedShapshot, IDisposable
|
||||
internal class PublishedSnapshot : IPublishedSnapshot, IDisposable
|
||||
{
|
||||
private readonly PublishedSnapshotService _service;
|
||||
private bool _defaultPreview;
|
||||
@@ -13,7 +13,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PublishedShapshot(PublishedSnapshotService service, bool defaultPreview)
|
||||
public PublishedSnapshot(PublishedSnapshotService service, bool defaultPreview)
|
||||
{
|
||||
_service = service;
|
||||
_defaultPreview = defaultPreview;
|
||||
@@ -72,13 +72,13 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
private class ForcedPreviewObject : DisposableObject
|
||||
{
|
||||
private readonly PublishedShapshot _publishedShapshot;
|
||||
private readonly PublishedSnapshot _publishedSnapshot;
|
||||
private readonly bool _origPreview;
|
||||
private readonly Action<bool> _callback;
|
||||
|
||||
public ForcedPreviewObject(PublishedShapshot publishedShapshot, bool preview, Action<bool> callback)
|
||||
public ForcedPreviewObject(PublishedSnapshot publishedShapshot, bool preview, Action<bool> callback)
|
||||
{
|
||||
_publishedShapshot = publishedShapshot;
|
||||
_publishedSnapshot = publishedShapshot;
|
||||
_callback = callback;
|
||||
|
||||
// save and force
|
||||
@@ -89,7 +89,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
// restore
|
||||
_publishedShapshot._defaultPreview = _origPreview;
|
||||
_publishedSnapshot._defaultPreview = _origPreview;
|
||||
_callback?.Invoke(_origPreview);
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
if (draftChanged || publishedChanged)
|
||||
((PublishedShapshot)CurrentPublishedShapshot).Resync();
|
||||
((PublishedSnapshot)CurrentPublishedSnapshot).Resync();
|
||||
}
|
||||
|
||||
private void NotifyLocked(IEnumerable<ContentCacheRefresher.JsonPayload> payloads, out bool draftChanged, out bool publishedChanged)
|
||||
@@ -630,7 +630,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
|
||||
if (anythingChanged)
|
||||
((PublishedShapshot)CurrentPublishedShapshot).Resync();
|
||||
((PublishedSnapshot)CurrentPublishedSnapshot).Resync();
|
||||
}
|
||||
|
||||
private void NotifyLocked(IEnumerable<MediaCacheRefresher.JsonPayload> payloads, out bool anythingChanged)
|
||||
@@ -719,7 +719,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked);
|
||||
Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked);
|
||||
|
||||
((PublishedShapshot)CurrentPublishedShapshot).Resync();
|
||||
((PublishedSnapshot)CurrentPublishedSnapshot).Resync();
|
||||
}
|
||||
|
||||
private void Notify<T>(ContentStore store, ContentTypeCacheRefresher.JsonPayload[] payloads, Action<IEnumerable<int>, IEnumerable<int>, IEnumerable<int>, IEnumerable<int>> action)
|
||||
@@ -796,7 +796,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
((PublishedShapshot)CurrentPublishedShapshot).Resync();
|
||||
((PublishedSnapshot)CurrentPublishedSnapshot).Resync();
|
||||
}
|
||||
|
||||
public override void Notify(DomainCacheRefresher.JsonPayload[] payloads)
|
||||
@@ -945,17 +945,17 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
private long _contentGen, _mediaGen, _domainGen;
|
||||
private ICacheProvider _elementsCache;
|
||||
|
||||
public override IPublishedShapshot CreatePublishedSnapshot(string previewToken)
|
||||
public override IPublishedSnapshot CreatePublishedSnapshot(string previewToken)
|
||||
{
|
||||
// no cache, no joy
|
||||
if (_isReady == false)
|
||||
throw new InvalidOperationException("The published snapshot service has not properly initialized.");
|
||||
|
||||
var preview = previewToken.IsNullOrWhiteSpace() == false;
|
||||
return new PublishedShapshot(this, preview);
|
||||
return new PublishedSnapshot(this, preview);
|
||||
}
|
||||
|
||||
public PublishedShapshot.PublishedSnapshotElements GetElements(bool previewDefault)
|
||||
public PublishedSnapshot.PublishedSnapshotElements GetElements(bool previewDefault)
|
||||
{
|
||||
// note: using ObjectCacheRuntimeCacheProvider for elements and snapshot caches
|
||||
// is not recommended because it creates an inner MemoryCache which is a heavy
|
||||
@@ -996,7 +996,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// a MaxValue to make sure this one runs last, and it should be ok
|
||||
scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Resync", () => this, (completed, svc) =>
|
||||
{
|
||||
((PublishedShapshot)svc.CurrentPublishedShapshot).Resync();
|
||||
((PublishedSnapshot)svc.CurrentPublishedSnapshot).Resync();
|
||||
}, int.MaxValue);
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var domainCache = new DomainCache(domainSnap);
|
||||
var domainHelper = new DomainHelper(domainCache, _siteDomainHelper);
|
||||
|
||||
return new PublishedShapshot.PublishedSnapshotElements
|
||||
return new PublishedSnapshot.PublishedSnapshotElements
|
||||
{
|
||||
ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, domainHelper, _globalSettings, _serviceContext.LocalizationService),
|
||||
MediaCache = new MediaCache(previewDefault, mediaSnap, snapshotCache, elementsCache),
|
||||
|
||||
Reference in New Issue
Block a user