using Umbraco.Cms.Core.Models.Entities; namespace Umbraco.Cms.Core.Cache; public interface IRepositoryCachePolicy where TEntity : class, IEntity { /// /// Gets an entity from the cache, else from the repository. /// /// The identifier. /// The repository PerformGet method. /// The repository PerformGetAll method. /// The entity with the specified identifier, if it exits, else null. /// First considers the cache then the repository. TEntity? Get(TId? id, Func performGet, Func?> performGetAll); /// /// Gets an entity from the cache. /// /// The identifier. /// The entity with the specified identifier, if it is in the cache already, else null. /// Does not consider the repository at all. TEntity? GetCached(TId id); /// /// Gets a value indicating whether an entity with a specified identifier exists. /// /// The identifier. /// The repository PerformExists method. /// The repository PerformGetAll method. /// A value indicating whether an entity with the specified identifier exists. /// First considers the cache then the repository. bool Exists(TId id, Func performExists, Func?> performGetAll); /// /// Creates an entity. /// /// The entity. /// The repository PersistNewItem method. /// Creates the entity in the repository, and updates the cache accordingly. void Create(TEntity entity, Action persistNew); /// /// Updates an entity. /// /// The entity. /// The repository PersistUpdatedItem method. /// Updates the entity in the repository, and updates the cache accordingly. void Update(TEntity entity, Action persistUpdated); /// /// Removes an entity. /// /// The entity. /// The repository PersistDeletedItem method. /// Removes the entity from the repository and clears the cache. void Delete(TEntity entity, Action persistDeleted); /// /// Gets entities. /// /// The identifiers. /// The repository PerformGetAll method. /// If is empty, all entities, else the entities with the specified identifiers. /// Get all the entities. Either from the cache or the repository depending on the implementation. TEntity[] GetAll(TId[]? ids, Func> performGetAll); /// /// Clears the entire cache. /// void ClearAll(); }