New IPublishedSnapshotStatus, reduces IPublishedSnapshotService

This commit is contained in:
Shannon
2020-12-21 17:41:12 +11:00
parent e8f5aa8ebc
commit c761fa0506
10 changed files with 146 additions and 117 deletions

View File

@@ -1352,7 +1352,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
// reading _floorGen is safe if _collectTask is null
if (_collectTask == null && _collectAuto && _liveGen - _floorGen > CollectMinGenDelta)
{
CollectAsyncLocked();
}
return snapshot;
}
@@ -1374,8 +1376,17 @@ namespace Umbraco.Web.PublishedCache.NuCache
private Task CollectAsyncLocked()
{
// NOTE: What in the heck is going on here? Why is any of this running in async contexts?
// SD: From what I can tell this was designed to be a set and forget background task to do the
// collecting which is why it's called from non-async methods within this class. This is
// slightly dangerous because it's not taking into account app shutdown.
// TODO: There should be a different method or class responsible for executing the cleanup on a
// background (set and forget) thread.
if (_collectTask != null)
{
return _collectTask;
}
// ReSharper disable InconsistentlySynchronizedField
var task = _collectTask = Task.Run((Action)Collect);