コード例 #1
0
        protected override async Task OnLoadSnapshot(
            CatchupCacheSubscriptionHolder <TAggregate>[]?catchupCacheSubscriptionHolders,
            ISnapshotStrategy?snapshotStrategy,
            ISnapshotStore <TAggregate>?snapshotStore)
        {
            if (UseSnapshot)
            {
#nullable disable

                var eventTypeFilter = GetEventsFilters();

                foreach (var catchupCacheSubscriptionHolder in catchupCacheSubscriptionHolders)
                {
                    var snapshot = await snapshotStore.GetByVersionOrLast(catchupCacheSubscriptionHolder.StreamId, eventTypeFilter);

                    if (null == snapshot)
                    {
                        continue;
                    }

                    catchupCacheSubscriptionHolder.CurrentSnapshotEventVersion      = snapshot.VersionFromSnapshot;
                    catchupCacheSubscriptionHolder.LastProcessedEventSequenceNumber = snapshot.VersionFromSnapshot;
                    catchupCacheSubscriptionHolder.LastProcessedEventUtcTimestamp   = DateTime.UtcNow;

                    Logger?.LogInformation($"{Id} => OnLoadSnapshot - EntityId: {snapshot.EntityId} StreamId: {snapshot.EntityId}");

                    CurrentCache.AddOrUpdate(snapshot);
                }

#nullable disable
            }