Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IMediaCacheService

    Defines operations for the media cache service.

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

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

    Methods

    View Source

    GetByContentType(IPublishedContentType)

    Gets all published media 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 media items of the specified type.

    View Source

    GetByIdAsync(int)

    Gets a published media item by its integer identifier.

    Declaration
    Task<IPublishedContent?> GetByIdAsync(int id)
    Parameters
    Type Name Description
    int id

    The integer identifier of the media.

    Returns
    Type Description
    Task<IPublishedContent>

    The published media content, or null if not found.

    View Source

    GetByKeyAsync(Guid)

    Gets a published media item by its unique key.

    Declaration
    Task<IPublishedContent?> GetByKeyAsync(Guid key)
    Parameters
    Type Name Description
    Guid key

    The unique key of the media.

    Returns
    Type Description
    Task<IPublishedContent>

    The published media content, or null if not found.

    View Source

    HasContentByIdAsync(int)

    Determines whether media with the specified identifier exists in the cache.

    Declaration
    Task<bool> HasContentByIdAsync(int id)
    Parameters
    Type Name Description
    int id

    The integer identifier of the media.

    Returns
    Type Description
    Task<bool>

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

    View Source

    RefreshMediaAsync(IMedia)

    Refreshes the cache entry for the specified media item.

    Declaration
    Task RefreshMediaAsync(IMedia media)
    Parameters
    Type Name Description
    IMedia media

    The media item to refresh in the cache.

    Returns
    Type Description
    Task

    A task representing the asynchronous operation.

    View Source

    TryGetCached(Guid, out IPublishedContent?)

    Attempts to retrieve a media item from the in-memory converted-content cache without touching the distributed cache or the database.

    Declaration
    bool TryGetCached(Guid key, out IPublishedContent? content)
    Parameters
    Type Name Description
    Guid key

    The unique key of the media.

    IPublishedContent content

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

    Returns
    Type Description
    bool

    true if the media 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. IPublishedMediaCache.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.

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