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

ContextualTtl

public class ContextualTtl : ITtlStrategy
Defines a ttl strategy which will cache items for a TimeSpan which may be influenced by data in the execution context.
public static readonly string SlidingExpirationKey

The key on the execution Context to use for storing whether the Ttl should be treated as sliding expiration. If no value is provided for this key, a ttl will not be treated as sliding expiration.

public static readonly string TimeSpanKey

The key on the execution Context to use for storing the Ttl TimeSpan for which to cache.

public ContextualTtl()

public Ttl GetTtl(Context context)

Gets the TimeSpan for which to keep an item about to be cached, which may be influenced by data in the execution context.