2021-02-18 11:06:02 +01:00
using Umbraco.Cms.Core.PublishedCache ;
using Umbraco.Cms.Infrastructure.PublishedCache.Persistence ;
2020-12-21 17:41:12 +11:00
2021-02-18 11:06:02 +01:00
namespace Umbraco.Cms.Infrastructure.PublishedCache
2020-12-21 17:41:12 +11:00
{
/// <summary>
/// Generates a status report for <see cref="PublishedSnapshotService"/>
/// </summary>
internal class PublishedSnapshotStatus : IPublishedSnapshotStatus
{
private readonly PublishedSnapshotService _service ;
private readonly INuCacheContentService _publishedContentService ;
public PublishedSnapshotStatus ( PublishedSnapshotService service , INuCacheContentService publishedContentService )
{
_service = service ;
_publishedContentService = publishedContentService ;
}
/// <inheritdoc/>
public virtual string StatusUrl = > "views/dashboard/settings/publishedsnapshotcache.html" ;
/// <inheritdoc/>
public string GetStatus ( )
{
_service . EnsureCaches ( ) ;
var dbCacheIsOk = _publishedContentService . VerifyContentDbCache ( )
& & _publishedContentService . VerifyMediaDbCache ( )
2020-12-23 10:45:52 +11:00
& & _publishedContentService . VerifyMemberDbCache ( )
? "ok"
: "NOT ok (rebuild?)" ;
2020-12-21 17:41:12 +11:00
ContentStore contentStore = _service . GetContentStore ( ) ;
ContentStore mediaStore = _service . GetMediaStore ( ) ;
2020-12-23 10:45:52 +11:00
var contentStoreGen = contentStore . GenCount ;
var mediaStoreGen = mediaStore . GenCount ;
var contentStoreSnap = contentStore . SnapCount ;
var mediaStoreSnap = mediaStore . SnapCount ;
var contentStoreCount = contentStore . Count ;
var mediaStoreCount = mediaStore . Count ;
string contentStoreCountPlural = contentStoreCount > 1 ? "s" : string . Empty ;
string contentStoreGenPlural = contentStoreGen > 1 ? "s" : string . Empty ;
string contentStoreSnapPlural = contentStoreSnap > 1 ? "s" : string . Empty ;
string mediaStoreCountPlural = mediaStoreCount > 1 ? "s" : string . Empty ;
string mediaStoreGenPlural = mediaStoreGen > 1 ? "s" : string . Empty ;
string mediaStoreSnapPlural = mediaStoreSnap > 1 ? "s" : string . Empty ;
return $" Database cache is {dbCacheIsOk}. ContentStore contains {contentStoreCount} item{contentStoreCountPlural} and has {contentStoreGen} generation{contentStoreGenPlural} and {contentStoreSnap} snapshot{contentStoreSnapPlural}. MediaStore contains {mediaStoreCount} item{mediaStoreCountPlural} and has {mediaStoreGen} generation{mediaStoreGenPlural} and {mediaStoreSnap} snapshot{mediaStoreSnapPlural}." ;
2020-12-21 17:41:12 +11:00
}
}
}