Interface IDocumentCacheService
Defines operations for the document (content) cache service.
Namespace: Umbraco.Cms.Core.PublishedCache
Assembly: Umbraco.Core.dll
Syntax
public interface IDocumentCacheService : IContentCacheService
Remarks
This service provides access to published document content with caching support, including operations for cache seeding, refreshing, and rebuilding.
Methods
View SourceGetByContentType(IPublishedContentType)
Gets all published content items of the specified content type.
Declaration
IEnumerable<IPublishedContent> GetByContentType(IPublishedContentType contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContentType | contentType | The published content type to filter by. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IPublishedContent> | A collection of published content items of the specified type. |
GetByIdAsync(int, bool?)
Gets a published content item by its integer identifier.
Declaration
Task<IPublishedContent?> GetByIdAsync(int id, bool? preview = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The integer identifier of the content. |
| bool? | preview | Optional value indicating whether to include unpublished content. If |
Returns
| Type | Description |
|---|---|
| Task<IPublishedContent> | The published content, or |
GetByKeyAsync(Guid, bool?)
Gets a published content item by its unique key.
Declaration
Task<IPublishedContent?> GetByKeyAsync(Guid key, bool? preview = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the content. |
| bool? | preview | Optional value indicating whether to include unpublished content. If |
Returns
| Type | Description |
|---|---|
| Task<IPublishedContent> | The published content, or |
HasContentByIdAsync(int, bool)
Determines whether content with the specified identifier exists in the cache.
Declaration
Task<bool> HasContentByIdAsync(int id, bool preview = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The integer identifier of the content. |
| bool | preview | A value indicating whether to check for unpublished content. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
|
RefreshContentAsync(IContent)
Refreshes the cache entry for the specified content item.
Declaration
Task RefreshContentAsync(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The content item to refresh in the cache. |
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous operation. |
TryGetCached(Guid, bool, out IPublishedContent?)
Attempts to retrieve a content item from the in-memory converted-content cache without touching the distributed cache or the database.
Declaration
bool TryGetCached(Guid key, bool preview, out IPublishedContent? content)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the content. |
| bool | preview | Whether to consider unpublished content. |
| IPublishedContent | content | When this method returns, contains the cached published content if a hit was made; otherwise |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Synchronous fast-path used by sync consumers (e.g. IPublishedContentCache.GetById(bool, Guid))
to avoid setting up the async state machine on the dominant warm-cache case. On a miss
the caller falls back to the existing async path. The default implementation always
returns false so the caller takes the async path.