Pass preview to GetEntryOptions (#18470)

This commit is contained in:
Nikolaj Geisle
2025-02-26 22:48:03 +01:00
committed by GitHub
parent 07bb2d1840
commit 2bdeefec16

View File

@@ -126,7 +126,7 @@ internal sealed class DocumentCacheService : IDocumentCacheService
scope.Complete();
return contentCacheNode;
},
GetEntryOptions(key));
GetEntryOptions(key, preview));
// We don't want to cache removed items, this may cause issues if the L2 serializer changes.
if (contentCacheNode is null)
@@ -209,13 +209,13 @@ internal sealed class DocumentCacheService : IDocumentCacheService
ContentCacheNode? draftNode = await _databaseCacheRepository.GetContentSourceAsync(key, true);
if (draftNode is not null)
{
await _hybridCache.SetAsync(GetCacheKey(draftNode.Key, true), draftNode, GetEntryOptions(draftNode.Key));
await _hybridCache.SetAsync(GetCacheKey(draftNode.Key, true), draftNode, GetEntryOptions(draftNode.Key, true));
}
ContentCacheNode? publishedNode = await _databaseCacheRepository.GetContentSourceAsync(key, false);
if (publishedNode is not null && HasPublishedAncestorPath(publishedNode.Key))
{
await _hybridCache.SetAsync(GetCacheKey(publishedNode.Key, false), publishedNode, GetEntryOptions(publishedNode.Key));
await _hybridCache.SetAsync(GetCacheKey(publishedNode.Key, false), publishedNode, GetEntryOptions(publishedNode.Key, false));
}
scope.Complete();
@@ -276,9 +276,9 @@ internal sealed class DocumentCacheService : IDocumentCacheService
LocalCacheExpiration = _cacheSettings.Entry.Document.SeedCacheDuration
};
private HybridCacheEntryOptions GetEntryOptions(Guid key)
private HybridCacheEntryOptions GetEntryOptions(Guid key, bool preview)
{
if (SeedKeys.Contains(key))
if (SeedKeys.Contains(key) && preview is false)
{
return GetSeedEntryOptions();
}