SlidingTtl
using System;
using System.Runtime.CompilerServices;
namespace Polly.Caching
{
public class SlidingTtl : ITtlStrategy, ITtlStrategy<object>
{
private readonly Ttl ttl;
public SlidingTtl(TimeSpan slidingTtl)
{
if (slidingTtl < TimeSpan.Zero)
throw new ArgumentOutOfRangeException("slidingTtl", "The ttl for items to cache must be greater than zero.");
ttl = new Ttl(slidingTtl, true);
}
[System.Runtime.CompilerServices.NullableContext(1)]
public Ttl GetTtl(Context context, [System.Runtime.CompilerServices.Nullable(2)] object result)
{
return ttl;
}
}
}