* Rename Umbraco.Core namespace to Umbraco.Cms.Core * Move extension methods in core project to Umbraco.Extensions * Move extension methods in core project to Umbraco.Extensions * Rename Umbraco.Examine namespace to Umbraco.Cms.Examine * Move examine extensions to Umbraco.Extensions namespace * Reflect changed namespaces in Builder and fix unit tests * Adjust namespace in Umbraco.ModelsBuilder.Embedded * Adjust namespace in Umbraco.Persistence.SqlCe * Adjust namespace in Umbraco.PublishedCache.NuCache * Align namespaces in Umbraco.Web.BackOffice * Align namespaces in Umbraco.Web.Common * Ensure that SqlCeSupport is still enabled after changing the namespace * Align namespaces in Umbraco.Web.Website * Align namespaces in Umbraco.Web.UI.NetCore * Align namespaces in Umbraco.Tests.Common * Align namespaces in Umbraco.Tests.UnitTests * Align namespaces in Umbraco.Tests.Integration * Fix errors caused by changed namespaces * Fix integration tests * Undo the Umbraco.Examine.Lucene namespace change This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows. * Fix merge * Fix Merge
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Umbraco.Cms.Core.Cache;
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
using Umbraco.Cms.Web.Common.Attributes;
|
|
using Umbraco.Extensions;
|
|
using Constants = Umbraco.Cms.Core.Constants;
|
|
|
|
namespace Umbraco.Cms.Web.BackOffice.Controllers
|
|
{
|
|
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
|
public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController
|
|
{
|
|
private readonly IPublishedSnapshotService _publishedSnapshotService;
|
|
private readonly IPublishedSnapshotStatus _publishedSnapshotStatus;
|
|
private readonly 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 _publishedSnapshotStatus.GetStatus();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a status report
|
|
/// </summary>
|
|
[HttpGet]
|
|
public string GetStatus() => _publishedSnapshotStatus.GetStatus();
|
|
|
|
/// <summary>
|
|
/// Cleans up unused snapshots
|
|
/// </summary>
|
|
[HttpGet]
|
|
public async Task<string> Collect()
|
|
{
|
|
GC.Collect();
|
|
await _publishedSnapshotService.CollectAsync();
|
|
return _publishedSnapshotStatus.GetStatus();
|
|
}
|
|
|
|
[HttpPost]
|
|
public void ReloadCache() => _distributedCache.RefreshAllPublishedSnapshot();
|
|
}
|
|
}
|