Class SnapshotRepository
Saves and gets snapshots to and from a snapshot store.
public class SnapshotRepository : IChangeRepository
- Inheritance
-
SnapshotRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
SnapshotRepository(IChangeStore, IChangeRepository, ISnapshotStore, ISnapshotStrategy)
Constructs a new SnapshotRepository instance.
public SnapshotRepository(IChangeStore changeStore, IChangeRepository changeRepository, ISnapshotStore snapshotStore, ISnapshotStrategy snapshotStrategy)
Parameters
changeStoreIChangeStoreStore where changes are persisted
changeRepositoryIChangeRepositoryRepository to get aggregates from the change store
snapshotStoreISnapshotStoreStore where snapshots are persisted
snapshotStrategyISnapshotStrategyStrategy used to determine when to take a snapshot
Methods
Box<T>(T)
Copies an aggregate to offline storage and removes it from online logs.
public void Box<T>(T aggregate) where T : AggregateRoot
Parameters
aggregateT
Type Parameters
T
Exists<T>(Guid)
Returns true if an aggregate exists.
public bool Exists<T>(Guid aggregate)
Parameters
aggregateGuid
Returns
Type Parameters
T
GetClone<T>(Guid, int?)
public T GetClone<T>(Guid aggregateId, int? expectedVersion = -1) where T : AggregateRoot
Parameters
Returns
- T
Type Parameters
T
GetPrevAndCurrentStates(Guid, int)
public (AggregateState prev, AggregateState current) GetPrevAndCurrentStates(Guid aggregateId, int version)
Parameters
Returns
GetStatesAndChanges(Guid)
public IChange[] GetStatesAndChanges(Guid aggregateId)
Parameters
aggregateIdGuid
Returns
- IChange[]
Get<T>(Guid, int?)
Gets the aggregate.
public T Get<T>(Guid aggregateId, int? version = -1) where T : AggregateRoot
Parameters
Returns
- T
Type Parameters
T
LockAndRun<T>(Guid, Action<T>)
public void LockAndRun<T>(Guid aggregateId, Action<T> action) where T : AggregateRoot
Parameters
Type Parameters
T
Peek<T>(Guid, int)
Returns a specific aggregate as at a specific version.
public T Peek<T>(Guid _, int __) where T : AggregateRoot
Parameters
Returns
- T
Type Parameters
T
Ping()
Checks for expired aggregates. Automatically boxes all aggregates for which the timer is now elapsed.
public void Ping()
Save<T>(T, int?)
Saves the aggregate. Takes a snapshot if needed.
public IChange[] Save<T>(T aggregate, int? version = null) where T : AggregateRoot
Parameters
aggregateTversionint?
Returns
- IChange[]
Type Parameters
T
Unbox<T>(Guid)
Retrieves an aggregate from offline storage and returns only its most recent state.
public T Unbox<T>(Guid aggregateId) where T : AggregateRoot
Parameters
aggregateIdGuid
Returns
- T
Type Parameters
T