U4-8400 - kill repository cache policy factories

This commit is contained in:
Stephan
2016-06-01 14:31:33 +02:00
parent 743a1451f5
commit bc375e5fc2
24 changed files with 429 additions and 484 deletions

View File

@@ -9,52 +9,39 @@ namespace Umbraco.Core.Cache
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <typeparam name="TId">The type of the identifier.</typeparam>
internal abstract class RepositoryCachePolicyBase<TEntity, TId> : DisposableObject, IRepositoryCachePolicy<TEntity, TId>
internal abstract class RepositoryCachePolicyBase<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId>
where TEntity : class, IAggregateRoot
{
private Action _action;
protected RepositoryCachePolicyBase(IRuntimeCacheProvider cache)
{
if (cache == null) throw new ArgumentNullException(nameof(cache));
Cache = cache;
}
}
protected IRuntimeCacheProvider Cache { get; }
/// <summary>
/// Disposing performs the actual caching action.
/// </summary>
protected override void DisposeResources()
{
_action?.Invoke();
}
/// <summary>
/// Sets the action to execute when being disposed.
/// </summary>
/// <param name="action">An action to perform when being disposed.</param>
protected void SetCacheAction(Action action)
{
_action = action;
}
/// <inheritdoc />
public abstract TEntity Get(TId id, Func<TId, TEntity> performGet, Func<TId[], IEnumerable<TEntity>> performGetAll);
/// <inheritdoc />
public abstract TEntity Get(TId id, Func<TId, TEntity> repoGet);
public abstract TEntity GetCached(TId id);
/// <inheritdoc />
public abstract TEntity Get(TId id);
public abstract bool Exists(TId id, Func<TId, bool> performExists, Func<TId[], IEnumerable<TEntity>> performGetAll);
/// <inheritdoc />
public abstract bool Exists(TId id, Func<TId, bool> repoExists);
public abstract void Create(TEntity entity, Action<TEntity> persistNew);
/// <inheritdoc />
public abstract void CreateOrUpdate(TEntity entity, Action<TEntity> repoCreateOrUpdate);
public abstract void Update(TEntity entity, Action<TEntity> persistUpdated);
/// <inheritdoc />
public abstract void Remove(TEntity entity, Action<TEntity> repoRemove);
public abstract void Delete(TEntity entity, Action<TEntity> persistDeleted);
/// <inheritdoc />
public abstract TEntity[] GetAll(TId[] ids, Func<TId[], IEnumerable<TEntity>> repoGet);
public abstract TEntity[] GetAll(TId[] ids, Func<TId[], IEnumerable<TEntity>> performGetAll);
/// <inheritdoc />
public abstract void ClearAll();
}
}