2020-02-04 19:18:35 +01:00
|
|
|
|
using System;
|
2020-05-27 14:14:32 +02:00
|
|
|
|
using System.Reflection.Metadata;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Umbraco.Core;
|
2020-02-04 19:18:35 +01:00
|
|
|
|
using Umbraco.Web.Cache;
|
2020-05-27 14:14:32 +02:00
|
|
|
|
using Umbraco.Web.Common.Attributes;
|
2020-02-04 19:18:35 +01:00
|
|
|
|
using Umbraco.Web.PublishedCache;
|
|
|
|
|
|
|
2020-05-27 14:14:32 +02:00
|
|
|
|
namespace Umbraco.Web.BackOffice.Controllers
|
2020-02-04 19:18:35 +01:00
|
|
|
|
{
|
2020-11-27 13:35:22 +01:00
|
|
|
|
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
2020-02-04 19:18:35 +01:00
|
|
|
|
public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
2020-05-27 14:14:32 +02:00
|
|
|
|
private readonly DistributedCache _distributedCache;
|
2020-02-04 19:18:35 +01:00
|
|
|
|
|
2020-05-27 14:14:32 +02:00
|
|
|
|
public PublishedSnapshotCacheStatusController(IPublishedSnapshotService publishedSnapshotService, DistributedCache distributedCache)
|
2020-02-04 19:18:35 +01:00
|
|
|
|
{
|
|
|
|
|
|
_publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService));
|
2020-05-27 14:14:32 +02:00
|
|
|
|
_distributedCache = distributedCache;
|
2020-02-04 19:18:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[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()
|
|
|
|
|
|
{
|
2020-05-27 14:14:32 +02:00
|
|
|
|
_distributedCache.RefreshAllPublishedSnapshot();
|
2020-02-04 19:18:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|