New IPublishedSnapshotStatus, reduces IPublishedSnapshotService
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Cache;
|
||||
@@ -8,43 +9,54 @@ using Umbraco.Web.PublishedCache;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.Controllers
|
||||
{
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController
|
||||
{
|
||||
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
||||
private readonly IPublishedSnapshotStatus _publishedSnapshotStatus;
|
||||
private readonly DistributedCache _distributedCache;
|
||||
|
||||
public PublishedSnapshotCacheStatusController(IPublishedSnapshotService publishedSnapshotService, DistributedCache distributedCache)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PublishedSnapshotCacheStatusController"/> class.
|
||||
/// </summary>
|
||||
public PublishedSnapshotCacheStatusController(
|
||||
IPublishedSnapshotService publishedSnapshotService,
|
||||
IPublishedSnapshotStatus publishedSnapshotStatus,
|
||||
DistributedCache distributedCache)
|
||||
{
|
||||
_publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService));
|
||||
_publishedSnapshotStatus = publishedSnapshotStatus;
|
||||
_distributedCache = distributedCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rebuilds the Database cache
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public string RebuildDbCache()
|
||||
{
|
||||
_publishedSnapshotService.Rebuild();
|
||||
return _publishedSnapshotService.GetStatus();
|
||||
return _publishedSnapshotStatus.GetStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a status report
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public string GetStatus()
|
||||
{
|
||||
return _publishedSnapshotService.GetStatus();
|
||||
}
|
||||
public string GetStatus() => _publishedSnapshotStatus.GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up unused snapshots
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public string Collect()
|
||||
public async Task<string> Collect()
|
||||
{
|
||||
GC.Collect();
|
||||
_publishedSnapshotService.Collect();
|
||||
return _publishedSnapshotService.GetStatus();
|
||||
await _publishedSnapshotService.CollectAsync();
|
||||
return _publishedSnapshotStatus.GetStatus();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ReloadCache()
|
||||
{
|
||||
_distributedCache.RefreshAllPublishedSnapshot();
|
||||
}
|
||||
public void ReloadCache() => _distributedCache.RefreshAllPublishedSnapshot();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user