Files
Umbraco-CMS/src/Umbraco.Core/Cache/NoCacheRepositoryCachePolicy.cs

60 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models.EntityBase;
2017-05-12 14:49:44 +02:00
using Umbraco.Core.Scoping;
namespace Umbraco.Core.Cache
{
2017-05-12 14:49:44 +02:00
internal class NoCacheRepositoryCachePolicy<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId>
where TEntity : class, IAggregateRoot
{
private NoCacheRepositoryCachePolicy() { }
2017-05-12 14:49:44 +02:00
public static NoCacheRepositoryCachePolicy<TEntity, TId> Instance { get; } = new NoCacheRepositoryCachePolicy<TEntity, TId>();
public IRepositoryCachePolicy<TEntity, TId> Scoped(IRuntimeCacheProvider runtimeCache, IScope scope)
{
2017-05-12 14:49:44 +02:00
throw new NotImplementedException();
}
2017-05-12 14:49:44 +02:00
public TEntity Get(TId id, Func<TId, TEntity> performGet, Func<TId[], IEnumerable<TEntity>> performGetAll)
{
2017-05-12 14:49:44 +02:00
return performGet(id);
}
2017-05-12 14:49:44 +02:00
public TEntity GetCached(TId id)
{
2017-05-12 14:49:44 +02:00
return null;
}
public bool Exists(TId id, Func<TId, bool> performExists, Func<TId[], IEnumerable<TEntity>> performGetAll)
{
return performExists(id);
}
2017-05-12 14:49:44 +02:00
public void Create(TEntity entity, Action<TEntity> persistNew)
{
2017-05-12 14:49:44 +02:00
persistNew(entity);
}
2017-05-12 14:49:44 +02:00
public void Update(TEntity entity, Action<TEntity> persistUpdated)
{
2017-05-12 14:49:44 +02:00
persistUpdated(entity);
}
2017-05-12 14:49:44 +02:00
public void Delete(TEntity entity, Action<TEntity> persistDeleted)
{
2017-05-12 14:49:44 +02:00
persistDeleted(entity);
}
2017-05-12 14:49:44 +02:00
public TEntity[] GetAll(TId[] ids, Func<TId[], IEnumerable<TEntity>> performGetAll)
{
2017-05-12 14:49:44 +02:00
return performGetAll(ids).ToArray();
}
2017-05-12 14:49:44 +02:00
public void ClearAll()
{ }
}
}