<PackageReference Include="Polly" Version="8.8.1" />

Polly.Caching.ResultTtl<TResult>

public class ResultTtl<TResult> : ITtlStrategy<TResult>
Defines a ttl strategy which can calculate a duration to cache items dynamically based on the execution context and result of the execution.
namespace Polly.Caching { public class ResultTtl<[System.Runtime.CompilerServices.Nullable(2)] TResult> : ITtlStrategy<TResult> { public ResultTtl(Func<TResult, Ttl> ttlFunc); public ResultTtl(Func<Context, TResult, Ttl> ttlFunc); public Ttl GetTtl(Context context, TResult result); } }