From 6a3d91503d1c9ba86c93e82ef4217c9dc1ea8acb Mon Sep 17 00:00:00 2001 From: Robertas Date: Tue, 16 Nov 2021 16:34:05 +0200 Subject: [PATCH] Changed cursor() into lazyById() to preserve memory when working with milions of events. --- src/StoredEvents/Repositories/EloquentStoredEventRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StoredEvents/Repositories/EloquentStoredEventRepository.php b/src/StoredEvents/Repositories/EloquentStoredEventRepository.php index 8966f29f..8f58d6c4 100644 --- a/src/StoredEvents/Repositories/EloquentStoredEventRepository.php +++ b/src/StoredEvents/Repositories/EloquentStoredEventRepository.php @@ -51,7 +51,7 @@ public function retrieveAllStartingFrom(int $startingFrom, string $uuid = null): /** @var LazyCollection $lazyCollection */ $lazyCollection = $query ->orderBy('id') - ->cursor(); + ->lazyById(); return $lazyCollection->map(fn (EloquentStoredEvent $storedEvent) => $storedEvent->toStoredEvent()); }