Interface IRepositoryCachePolicy<TEntity, TId>
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public interface IRepositoryCachePolicy<TEntity, TId>
where TEntity : class, IEntity
Type Parameters
Name | Description |
---|---|
TEntity | |
TId |
Methods
View SourceClearAll()
Clears the entire cache.
Declaration
void ClearAll()
Create(TEntity, Action<TEntity>)
Creates an entity.
Declaration
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.
Delete(TEntity, Action<TEntity>)
Removes an entity.
Declaration
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.
Exists(TId, Func<TId, Boolean>, Func<TId[], Nullable<IEnumerable<TEntity>>>)
Gets a value indicating whether an entity with a specified identifier exists.
Declaration
bool Exists(TId id, Func<TId, bool> performExists, Func<TId[], IEnumerable<TEntity>?> performGetAll)
Parameters
Type | Name | Description |
---|---|---|
TId | id | The identifier. |
Func<TId, System.Boolean> | performExists | The repository PerformExists method. |
Func<TId[], System.Nullable<IEnumerable<TEntity>>> | performGetAll | The repository PerformGetAll method. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether an entity with the specified identifier exists. |
Remarks
First considers the cache then the repository.
Get(TId, Func<TId, TEntity>, Func<TId[], Nullable<IEnumerable<TEntity>>>)
Gets an entity from the cache, else from the repository.
Declaration
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[], System.Nullable<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.
GetAll(TId[], Func<TId[], IEnumerable<TEntity>>)
Gets entities.
Declaration
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 |
Remarks
Get all the entities. Either from the cache or the repository depending on the implementation.
GetCached(TId)
Gets an entity from the cache.
Declaration
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.
Update(TEntity, Action<TEntity>)
Updates an entity.
Declaration
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.