Snapshots
Enabling snapshots
Snapshotting is an optimization that reduces time spent on reading events from an event store. We can enable snapshots by annotating our aggregate with @EnableSnapshots and specify a threshold. Once this threshold is reached, a new snapshot is created.
Enabling shapsots:
@AggregateRoot
@EnableSnapshots(threshold = 100)
public class Customer {
@AggregateId
private String id;
private String firstName;
private String lastName;
private String address;
// Getters & setters are omitted
}