Search Results for

    Show / Hide Table of Contents
    View Source

    Class SingleServerCacheVersionService

    A simple cache version service that assumes the cache is always in sync. This is useful in scenarios where you have a single server setup and do not need to manage cache synchronization across multiple servers.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Cache
    Assembly: Umbraco.Core.dll
    Syntax
    public class SingleServerCacheVersionService : IRepositoryCacheVersionService

    Constructors

    View Source

    SingleServerCacheVersionService()

    Declaration
    public SingleServerCacheVersionService()

    Methods

    View Source

    FlushCacheUpdatesAsync()

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

    Declaration
    public 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
    public 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
    public 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
    public 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
    public 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
    public 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