Performance: Cache published content instances at cache service level (#20681)

Cache published content instances at cache service level
This commit is contained in:
Kenn Jacobsen
2025-11-03 10:55:23 +01:00
committed by GitHub
parent 95cc6cc67b
commit 4ee1d7b13e
9 changed files with 508 additions and 257 deletions

View File

@@ -85,17 +85,50 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
Assert.IsFalse(textPage.IsPublished());
}
[Test]
public async Task Cannot_get_unpublished_content()
[TestCase(true)]
[TestCase(false)]
public async Task Can_Get_Unpublished_Content_By_Key(bool preview)
{
// Arrange
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
Assert.IsTrue(unpublishAttempt.Success);
//Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, false);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, preview);
// Assert
Assert.IsNull(textPage);
if (preview)
{
Assert.IsNotNull(textPage);
Assert.IsFalse(textPage.IsPublished());
}
else
{
Assert.IsNull(textPage);
}
}
[TestCase(true)]
[TestCase(false)]
public async Task Can_Get_Unpublished_Content_By_Id(bool preview)
{
// Arrange
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
Assert.IsTrue(unpublishAttempt.Success);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
// Assert
if (preview)
{
Assert.IsNotNull(textPage);
Assert.IsFalse(textPage.IsPublished());
}
else
{
Assert.IsNull(textPage);
}
}
[Test]