Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IDocumentCacheService

    Defines operations for the document (content) cache service.

    Namespace: Umbraco.Cms.Core.PublishedCache
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IDocumentCacheService
    Remarks

    This service provides access to published document content with caching support, including operations for cache seeding, refreshing, and rebuilding.

    Methods

    View Source

    ClearConvertedContentCache()

    Clears all converted IPublishedContent entries from the in-memory cache, without rebuilding the underlying database cache or HybridCache entries.

    Declaration
    void ClearConvertedContentCache()
    Remarks

    Use this when the published model factory is reset (e.g. InMemoryAuto mode), which invalidates all compiled model types and makes cached instances of any type stale.

    View Source

    ClearConvertedContentCache(IReadOnlyCollection<int>)

    Clears converted IPublishedContent entries for the specified content types from the in-memory cache, without rebuilding the underlying database cache or HybridCache entries.

    Declaration
    void ClearConvertedContentCache(IReadOnlyCollection<int> contentTypeIds)
    Parameters
    Type Name Description
    IReadOnlyCollection<int> contentTypeIds

    The IDs of the content types whose converted entries should be cleared.

    Remarks

    Use this when the published model factory is NOT reset (e.g. SourceCodeAuto/SourceCodeManual modes), so only the affected content types need their converted cache cleared.

    View Source

    ClearMemoryCacheAsync(CancellationToken)

    Clears all entries from the memory cache.

    Declaration
    Task ClearMemoryCacheAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A cancellation token to observe while waiting for the task to complete.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    DeleteItemAsync(IContentBase)

    Removes the specified content item from the cache.

    Declaration
    Task DeleteItemAsync(IContentBase content)
    Parameters
    Type Name Description
    IContentBase content

    The content item to remove from the cache.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    GetByContentType(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.

    View Source

    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 null, uses the default preview setting.

    Returns
    Type Description
    Task<IPublishedContent>

    The published content, or null if not found.

    View Source

    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 null, uses the default preview setting.

    Returns
    Type Description
    Task<IPublishedContent>

    The published content, or null if not found.

    View Source

    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>

    true if content with the specified identifier exists; otherwise, false.

    View Source

    Rebuild(IReadOnlyCollection<int>)

    Rebuilds the cache for content items of the specified content types.

    Declaration
    void Rebuild(IReadOnlyCollection<int> contentTypeIds)
    Parameters
    Type Name Description
    IReadOnlyCollection<int> contentTypeIds

    The collection of content type identifiers to rebuild.

    View Source

    RebuildMemoryCacheByContentTypeAsync(IEnumerable<int>)

    Rebuilds the memory cache for content items of the specified content types.

    Declaration
    Task RebuildMemoryCacheByContentTypeAsync(IEnumerable<int> contentTypeIds)
    Parameters
    Type Name Description
    IEnumerable<int> contentTypeIds

    The collection of content type identifiers to rebuild in memory cache.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    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.

    View Source

    RefreshMemoryCacheAsync(Guid)

    Refreshes the memory cache entry for the content item with the specified key.

    Declaration
    Task RefreshMemoryCacheAsync(Guid key)
    Parameters
    Type Name Description
    Guid key

    The unique key of the content to refresh.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    RemoveFromMemoryCacheAsync(Guid)

    Removes the content item with the specified key from the memory cache.

    Declaration
    Task RemoveFromMemoryCacheAsync(Guid key)
    Parameters
    Type Name Description
    Guid key

    The unique key of the content to remove.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    SeedAsync(CancellationToken)

    Seeds the cache with initial content data.

    Declaration
    Task SeedAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A cancellation token to observe while waiting for the task to complete.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX