2016-06-01 14:31:33 +02:00
|
|
|
|
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;
|
2016-06-01 14:31:33 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Cache
|
|
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
internal class NoCacheRepositoryCachePolicy<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId>
|
2016-06-01 14:31:33 +02:00
|
|
|
|
where TEntity : class, IAggregateRoot
|
|
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
private NoCacheRepositoryCachePolicy()
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
public static NoCacheRepositoryCachePolicy<TEntity, TId> Instance { get; } = new NoCacheRepositoryCachePolicy<TEntity, TId>();
|
|
|
|
|
|
|
|
|
|
|
|
public IRepositoryCachePolicy<TEntity, TId> Scoped(IRuntimeCacheProvider runtimeCache, IScope scope)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
throw new NotImplementedException();
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public TEntity Get(TId id, Func<TId, TEntity> performGet, Func<TId[], IEnumerable<TEntity>> performGetAll)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
return performGet(id);
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public TEntity GetCached(TId id)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
return null;
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
persistNew(entity);
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public void Update(TEntity entity, Action<TEntity> persistUpdated)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
persistUpdated(entity);
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public void Delete(TEntity entity, Action<TEntity> persistDeleted)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
persistDeleted(entity);
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public TEntity[] GetAll(TId[] ids, Func<TId[], IEnumerable<TEntity>> performGetAll)
|
2016-06-01 14:31:33 +02:00
|
|
|
|
{
|
2017-05-12 14:49:44 +02:00
|
|
|
|
return performGetAll(ids).ToArray();
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
|
|
|
|
|
public void ClearAll()
|
|
|
|
|
|
{ }
|
2016-06-01 14:31:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|