2016-01-07 16:31:20 +01:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Cache
|
2015-01-29 15:39:41 +11:00
|
|
|
{
|
2016-06-01 10:35:44 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Specifies how a repository cache policy should cache entities.
|
|
|
|
|
/// </summary>
|
2016-01-07 16:31:20 +01:00
|
|
|
internal class RepositoryCachePolicyOptions
|
2015-01-29 15:39:41 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2016-01-07 16:31:20 +01:00
|
|
|
/// Ctor - sets GetAllCacheValidateCount = true
|
2015-01-29 15:39:41 +11:00
|
|
|
/// </summary>
|
2016-01-07 16:31:20 +01:00
|
|
|
public RepositoryCachePolicyOptions(Func<int> performCount)
|
2015-01-29 15:39:41 +11:00
|
|
|
{
|
2016-01-07 16:31:20 +01:00
|
|
|
PerformCount = performCount;
|
2015-01-29 15:39:41 +11:00
|
|
|
GetAllCacheValidateCount = true;
|
|
|
|
|
GetAllCacheAllowZeroCount = false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 16:31:20 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Ctor - sets GetAllCacheValidateCount = false
|
|
|
|
|
/// </summary>
|
|
|
|
|
public RepositoryCachePolicyOptions()
|
|
|
|
|
{
|
|
|
|
|
PerformCount = null;
|
|
|
|
|
GetAllCacheValidateCount = false;
|
|
|
|
|
GetAllCacheAllowZeroCount = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Callback required to get count for GetAllCacheValidateCount
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Func<int> PerformCount { get; private set; }
|
|
|
|
|
|
2015-01-29 15:39:41 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// True/false as to validate the total item count when all items are returned from cache, the default is true but this
|
|
|
|
|
/// means that a db lookup will occur - though that lookup will probably be significantly less expensive than the normal
|
|
|
|
|
/// GetAll method.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// setting this to return false will improve performance of GetAll cache with no params but should only be used
|
|
|
|
|
/// for specific circumstances
|
|
|
|
|
/// </remarks>
|
2016-01-07 16:31:20 +01:00
|
|
|
public bool GetAllCacheValidateCount { get; private set; }
|
2015-01-29 15:39:41 +11:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// True if the GetAll method will cache that there are zero results so that the db is not hit when there are no results found
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool GetAllCacheAllowZeroCount { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|