Class PartitionedShieldOptions<TKey, TResult>

Namespace
Kevlar
Assembly
Kevlar.dll

Controls retention for a result-aware partitioned shield provider.

public sealed class PartitionedShieldOptions<TKey, TResult> where TKey : notnull

Type Parameters

TKey
TResult
Inheritance
PartitionedShieldOptions<TKey, TResult>
Inherited Members

Constructors

PartitionedShieldOptions()

public PartitionedShieldOptions()

Properties

IdleExpiration

Gets or sets the optional idle duration after which a partition may be evicted on the next provider operation. A null value disables idle expiry.

public TimeSpan? IdleExpiration { get; set; }

Property Value

TimeSpan?

MaxPartitions

Gets or sets the maximum number of retained partitions. The least recently used partition is evicted before this bound is exceeded. Defaults to 1,000.

public int MaxPartitions { get; set; }

Property Value

int

OnCreated

Invoked and awaited after a partition is created and retained. Return default from a synchronous callback. Disposing this provider from its own callback is rejected to prevent a lifecycle deadlock. Owned strategies remain alive until the callback and the creating lookup complete, even if the partition is concurrently evicted.

public Func<PartitionCreatedEvent<TKey, TResult>, ValueTask>? OnCreated { get; set; }

Property Value

Func<PartitionCreatedEvent<TKey, TResult>, ValueTask>

OnEvicted

Invoked and awaited after a partition is removed from the provider and before an automatically evicted partition's slot is reused. A cold lookup reentered from this callback may return an unretained shield when the invoking eviction owns all available capacity. Disposing this provider from either lifecycle callback is rejected to prevent a lifecycle deadlock. Return default from a synchronous callback.

public Func<PartitionEvictedEvent<TKey, TResult>, ValueTask>? OnEvicted { get; set; }

Property Value

Func<PartitionEvictedEvent<TKey, TResult>, ValueTask>

OwnsStrategies

Gets or sets whether the provider owns and disposes strategies returned by its factory. Defaults to true. Set to false when those strategy instances are also used by shields outside this provider.

public bool OwnsStrategies { get; set; }

Property Value

bool

TimeProvider

Gets or sets the time source used for idle expiry. Defaults to system time.

public TimeProvider TimeProvider { get; set; }

Property Value

TimeProvider