Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IElementCacheService

    Defines operations for the element cache service.

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

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

    Methods

    View Source

    GetByContentType(IPublishedContentType)

    Gets all published elements of the specified content type.

    Declaration
    IEnumerable<IPublishedElement> GetByContentType(IPublishedContentType contentType)
    Parameters
    Type Name Description
    IPublishedContentType contentType

    The published content type to filter by.

    Returns
    Type Description
    IEnumerable<IPublishedElement>

    A collection of published elements of the specified type.

    View Source

    GetByKeyAsync(Guid, bool?)

    Gets a published element by its unique key.

    Declaration
    Task<IPublishedElement?> GetByKeyAsync(Guid key, bool? preview = null)
    Parameters
    Type Name Description
    Guid key

    The unique key of the element.

    bool? preview

    Optional value indicating whether to include unpublished content. If null, defaults to false.

    Returns
    Type Description
    Task<IPublishedElement>

    The published element, or null if not found.

    View Source

    RefreshElementAsync(IElement)

    Refreshes the cache entry for the specified element.

    Declaration
    Task RefreshElementAsync(IElement element)
    Parameters
    Type Name Description
    IElement element

    The element to refresh in the cache.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    TryGetCached(Guid, bool, out IPublishedElement?)

    Attempts to retrieve an element from the in-memory converted-content cache without touching the distributed cache or the database.

    Declaration
    bool TryGetCached(Guid key, bool preview, out IPublishedElement? element)
    Parameters
    Type Name Description
    Guid key

    The unique key of the element.

    bool preview

    Whether to consider unpublished content.

    IPublishedElement element

    When this method returns, contains the cached published element if a hit was made; otherwise null.

    Returns
    Type Description
    bool

    true if the element was served from the in-memory cache; false if a slower retrieval (HybridCache or database) is required.

    Remarks

    Synchronous fast-path used by sync consumers (e.g. IPublishedElementCache.GetById(bool, Guid) and property value converters that sync-over-async) 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.

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