Table of Contents

Class IntervalSnapshotStrategy

Namespace
Excalibur.EventSourcing.Snapshots
Assembly
Excalibur.EventSourcing.dll

Snapshot strategy based on event count interval.

public sealed class IntervalSnapshotStrategy : ISnapshotStrategy
Inheritance
IntervalSnapshotStrategy
Implements
Inherited Members

Remarks

Creates a snapshot after a specified number of events have been applied to an aggregate. This is the most common snapshot strategy, providing predictable snapshot frequency.

Constructors

IntervalSnapshotStrategy(int)

Initializes a new instance of the IntervalSnapshotStrategy class.

public IntervalSnapshotStrategy(int interval = 100)

Parameters

interval int

The number of events between snapshots. Default is 100. Must be greater than zero.

Exceptions

ArgumentOutOfRangeException

Thrown when interval is less than or equal to zero. Validating here fails fast at configuration time rather than throwing DivideByZeroException on the snapshot-decision path for every aggregate (interval==0), or producing nonsensical results (negative interval).

Methods

ShouldCreateSnapshot(IAggregateRoot)

Determines whether a snapshot should be created for the aggregate.

[RequiresUnreferencedCode("Snapshot strategy evaluation may require types that cannot be statically analyzed. Consider using source generation.")]
[RequiresDynamicCode("Snapshot strategy evaluation may require dynamic code generation which is not compatible with AOT compilation.")]
public bool ShouldCreateSnapshot(IAggregateRoot aggregate)

Parameters

aggregate IAggregateRoot

The aggregate to check.

Returns

bool

True if a snapshot should be created, otherwise false.