Skip to content

Commit

Permalink
more snapshot documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hallgren committed Jun 13, 2018
1 parent ad7c843 commit 3d9f4fd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,12 @@ board.unsaved_events?

## Snapshot

If there is alot of events saved to an aggregate it can take some time to reload the current state of the aggregate via the `.find` method. This is because all events belonging to the aggregate has to be fetched and iterated one by one to build its current state. The snapshot functionallity makes it possible to store the current aggregate state and re-use it when loading the aggregate. The snapshot is used as a cache where only the events that has occured after the snapshot has to be fetched and used to build the current state of the aggregate.
If there is a lot of events saved to an aggregate it can take some time to reload the current state of the aggregate via the `.find` method. This is because all events belonging to the aggregate has to be fetched and iterated one by one to build its current state. The snapshot functionality makes it possible to store the current aggregate state and re-use it when loading the aggregate. The snapshot is used as a cache where only the events that has occurred after the snapshot has to be fetched and used to build the current state of the aggregate.

There is one global snapshot store where all snapshots are stored independent on aggregate_type. To enable snapshot on a aggregate_type the Class has to be added to the `snapshot_types` Array when configuring Sandthorn. The aggregate will now be stored to the snapshot_store on every `.save` and when using `.find` it will look for a snapshot of the requested aggregate.

Currently its only possible to store the snapshots in memory, so be careful not draining your applications memory space.


```ruby

Expand Down

0 comments on commit 3d9f4fd

Please sign in to comment.