Search Results for

    Show / Hide Table of Contents
    View Source

    Class RepositoryCachePolicyBase<TEntity, TId>

    A base class for repository cache policies.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Cache
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public abstract class RepositoryCachePolicyBase<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId> where TEntity : class, IEntity
    Type Parameters
    Name Description
    TEntity

    The type of the entity.

    TId

    The type of the identifier.

    Constructors

    View Source

    RepositoryCachePolicyBase(IAppPolicyCache, IScopeAccessor)

    Declaration
    [Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 18.")]
    protected RepositoryCachePolicyBase(IAppPolicyCache globalCache, IScopeAccessor scopeAccessor)
    Parameters
    Type Name Description
    IAppPolicyCache globalCache
    IScopeAccessor scopeAccessor
    View Source

    RepositoryCachePolicyBase(IAppPolicyCache, IScopeAccessor, IRepositoryCacheVersionService, ICacheSyncService)

    Declaration
    protected RepositoryCachePolicyBase(IAppPolicyCache globalCache, IScopeAccessor scopeAccessor, IRepositoryCacheVersionService cacheVersionService, ICacheSyncService cacheSyncService)
    Parameters
    Type Name Description
    IAppPolicyCache globalCache
    IScopeAccessor scopeAccessor
    IRepositoryCacheVersionService cacheVersionService
    ICacheSyncService cacheSyncService

    Properties

    View Source

    Cache

    Declaration
    protected IAppPolicyCache Cache { get; }
    Property Value
    Type Description
    IAppPolicyCache

    Methods

    View Source

    ClearAll()

    Clears the entire cache.

    Declaration
    public abstract void ClearAll()
    View Source

    Create(TEntity, Action<TEntity>)

    Creates an entity.

    Declaration
    public abstract void Create(TEntity entity, Action<TEntity> persistNew)
    Parameters
    Type Name Description
    TEntity entity

    The entity.

    Action<TEntity> persistNew

    The repository PersistNewItem method.

    Remarks

    Creates the entity in the repository, and updates the cache accordingly.

    View Source

    Delete(TEntity, Action<TEntity>)

    Removes an entity.

    Declaration
    public abstract void Delete(TEntity entity, Action<TEntity> persistDeleted)
    Parameters
    Type Name Description
    TEntity entity

    The entity.

    Action<TEntity> persistDeleted

    The repository PersistDeletedItem method.

    Remarks

    Removes the entity from the repository and clears the cache.

    View Source

    EnsureCacheIsSynced()

    Ensures that the cache is synced with the database.

    Declaration
    protected void EnsureCacheIsSynced()
    View Source

    Exists(TId, Func<TId, bool>, Func<TId[], IEnumerable<TEntity>?>)

    Gets a value indicating whether an entity with a specified identifier exists.

    Declaration
    public abstract bool Exists(TId id, Func<TId, bool> performExists, Func<TId[], IEnumerable<TEntity>?> performGetAll)
    Parameters
    Type Name Description
    TId id

    The identifier.

    Func<TId, bool> performExists

    The repository PerformExists method.

    Func<TId[], IEnumerable<TEntity>> performGetAll

    The repository PerformGetAll method.

    Returns
    Type Description
    bool

    A value indicating whether an entity with the specified identifier exists.

    Remarks

    First considers the cache then the repository.

    View Source

    Get(TId?, Func<TId?, TEntity?>, Func<TId[]?, IEnumerable<TEntity>?>)

    Gets an entity from the cache, else from the repository.

    Declaration
    public abstract TEntity? Get(TId? id, Func<TId?, TEntity?> performGet, Func<TId[]?, IEnumerable<TEntity>?> performGetAll)
    Parameters
    Type Name Description
    TId id

    The identifier.

    Func<TId, TEntity> performGet

    The repository PerformGet method.

    Func<TId[], IEnumerable<TEntity>> performGetAll

    The repository PerformGetAll method.

    Returns
    Type Description
    TEntity

    The entity with the specified identifier, if it exits, else null.

    Remarks

    First considers the cache then the repository.

    View Source

    GetAll(TId[]?, Func<TId[]?, IEnumerable<TEntity>?>)

    Gets entities.

    Declaration
    public abstract TEntity[] GetAll(TId[]? ids, Func<TId[]?, IEnumerable<TEntity>?> performGetAll)
    Parameters
    Type Name Description
    TId[] ids

    The identifiers.

    Func<TId[], IEnumerable<TEntity>> performGetAll

    The repository PerformGetAll method.

    Returns
    Type Description
    TEntity[]

    If ids is empty, all entities, else the entities with the specified identifiers.

    Remarks

    Get all the entities. Either from the cache or the repository depending on the implementation.

    View Source

    GetCached(TId)

    Gets an entity from the cache.

    Declaration
    public abstract TEntity? GetCached(TId id)
    Parameters
    Type Name Description
    TId id

    The identifier.

    Returns
    Type Description
    TEntity

    The entity with the specified identifier, if it is in the cache already, else null.

    Remarks

    Does not consider the repository at all.

    View Source

    RegisterCacheChange()

    Registers a change in the cache.

    Declaration
    protected void RegisterCacheChange()
    View Source

    Update(TEntity, Action<TEntity>)

    Updates an entity.

    Declaration
    public abstract void Update(TEntity entity, Action<TEntity> persistUpdated)
    Parameters
    Type Name Description
    TEntity entity

    The entity.

    Action<TEntity> persistUpdated

    The repository PersistUpdatedItem method.

    Remarks

    Updates the entity in the repository, and updates the cache accordingly.

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