UnitOfWork RIP, troubleshoot and fix, tests

This commit is contained in:
Stephan
2017-12-15 16:29:14 +01:00
parent 0ab2f6cc9f
commit bbff74fa51
79 changed files with 501 additions and 588 deletions

View File

@@ -24,18 +24,13 @@ namespace Umbraco.Core.Cache
private readonly Func<TEntity, TId> _entityGetId;
private readonly bool _expires;
public FullDataSetRepositoryCachePolicy(IRuntimeCacheProvider cache, Func<TEntity, TId> entityGetId, bool expires)
: base(cache)
public FullDataSetRepositoryCachePolicy(IRuntimeCacheProvider cache, IScopeAccessor scopeAccessor, Func<TEntity, TId> entityGetId, bool expires)
: base(cache, scopeAccessor)
{
_entityGetId = entityGetId;
_expires = expires;
}
public override IRepositoryCachePolicy<TEntity, TId> Scoped(IRuntimeCacheProvider runtimeCache, IScope scope)
{
return new ScopedRepositoryCachePolicy<TEntity, TId>(this, runtimeCache, scope);
}
protected static readonly TId[] EmptyIds = new TId[0]; // const
protected string GetEntityTypeCacheKey()
@@ -56,13 +51,15 @@ namespace Umbraco.Core.Cache
// set to ListCloneBehavior.CloneOnce ie it will clone *once* when inserting,
// and then will *not* clone when retrieving.
var key = GetEntityTypeCacheKey();
if (_expires)
{
Cache.InsertCacheItem(GetEntityTypeCacheKey(), () => new DeepCloneableList<TEntity>(entities), TimeSpan.FromMinutes(5), true);
Cache.InsertCacheItem(key, () => new DeepCloneableList<TEntity>(entities), TimeSpan.FromMinutes(5), true);
}
else
{
Cache.InsertCacheItem(GetEntityTypeCacheKey(), () => new DeepCloneableList<TEntity>(entities));
Cache.InsertCacheItem(key, () => new DeepCloneableList<TEntity>(entities));
}
}