This commit is contained in:
Bjarke Berg
2020-05-27 14:14:32 +02:00
parent 0108db553c
commit 00b7c2d13b
3 changed files with 15 additions and 11 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Reflection.Metadata;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Core;
using Umbraco.Web.Cache;
using Umbraco.Web.Common.Attributes;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.BackOffice.Controllers
{
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
[IsBackOffice]
public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController
{
private readonly IPublishedSnapshotService _publishedSnapshotService;
private readonly DistributedCache _distributedCache;
public PublishedSnapshotCacheStatusController(IPublishedSnapshotService publishedSnapshotService, DistributedCache distributedCache)
{
_publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService));
_distributedCache = distributedCache;
}
[HttpPost]
public string RebuildDbCache()
{
_publishedSnapshotService.Rebuild();
return _publishedSnapshotService.GetStatus();
}
[HttpGet]
public string GetStatus()
{
return _publishedSnapshotService.GetStatus();
}
[HttpGet]
public string Collect()
{
GC.Collect();
_publishedSnapshotService.Collect();
return _publishedSnapshotService.GetStatus();
}
[HttpPost]
public void ReloadCache()
{
_distributedCache.RefreshAllPublishedSnapshot();
}
}
}