Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IRepositoryCacheVersionService

    Provides methods to manage and validate cache versioning for repository entities, ensuring cache consistency with the underlying database.

    Namespace: Umbraco.Cms.Core.Cache
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IRepositoryCacheVersionService

    Methods

    View Source

    FlushCacheUpdatesAsync()

    Publishes the cache updates registered by SetCacheUpdatedAsync<TEntity>() whose publication was deferred.

    Declaration
    Task FlushCacheUpdatesAsync()
    Returns
    Type Description
    Task
    Remarks

    Called once the cache instructions for the current unit of work have been written. Implementations that publish updates immediately have nothing to do here.

    View Source

    GetCacheVersionsAsync()

    Gets the cache versions currently published for all entity types.

    Declaration
    Task<IReadOnlyCollection<RepositoryCacheVersion>> GetCacheVersionsAsync()
    Returns
    Type Description
    Task<IReadOnlyCollection<RepositoryCacheVersion>>

    The published cache versions; a version whose value is null has never been published.

    Remarks

    The synchronization reads this snapshot before processing the cache instructions and adopts it afterwards through SetCachesSyncedAsync(IEnumerable<RepositoryCacheVersion>), so the two must be implemented together. No snapshot can be derived from the other members, so the default implementation throws.

    Exceptions
    Type Condition
    NotImplementedException

    Thrown when the implementation does not provide the snapshot.

    View Source

    IsCacheSyncedAsync<TEntity>()

    Validates if the cache is synced with the database.

    Declaration
    Task<bool> IsCacheSyncedAsync<TEntity>() where TEntity : class
    Returns
    Type Description
    Task<bool>

    True if cache is synced, false if cache needs fast-forwarding.

    Type Parameters
    Name Description
    TEntity

    The type of the cached entity.

    View Source

    SetCacheUpdatedAsync<TEntity>()

    Registers a cache update for the specified entity type.

    Declaration
    Task SetCacheUpdatedAsync<TEntity>() where TEntity : class
    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    TEntity

    The type of the cached entity.

    Remarks

    Other servers detect the update through the published cache version. An implementation may defer publishing it until FlushCacheUpdatesAsync() is called, so that the version never becomes visible before the cache instructions that describe the change.

    View Source

    SetCachesSyncedAsync()

    Registers that the cache has been synced with the database.

    Declaration
    Task SetCachesSyncedAsync()
    Returns
    Type Description
    Task
    Remarks

    Adopts the versions currently published. Prefer SetCachesSyncedAsync(IEnumerable<RepositoryCacheVersion>) with versions read before the cache instructions were processed.

    View Source

    SetCachesSyncedAsync(IEnumerable<RepositoryCacheVersion>)

    Registers that the local caches have been synced up to the given cache versions.

    Declaration
    Task SetCachesSyncedAsync(IEnumerable<RepositoryCacheVersion> cacheVersions)
    Parameters
    Type Name Description
    IEnumerable<RepositoryCacheVersion> cacheVersions

    The versions read before the cache instructions were processed, typically from GetCacheVersionsAsync().

    Returns
    Type Description
    Task
    Remarks

    Adopting the versions read before processing, rather than the versions published afterwards, means a version published while instructions were being processed is still seen as out of date and triggers another sync. Concurrent syncs may adopt an older set last; that costs one redundant sync and nothing more. Delegating to SetCachesSyncedAsync() would discard the snapshot and reintroduce that race, so the default implementation throws instead.

    Exceptions
    Type Condition
    NotImplementedException

    Thrown when the implementation does not adopt the given snapshot.

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