diff --git a/src/Cheeper/Chapter9/DomainModel/EventStore.php b/src/Cheeper/Chapter9/DomainModel/EventStore.php index 14a7be3..c5f98d4 100644 --- a/src/Cheeper/Chapter9/DomainModel/EventStore.php +++ b/src/Cheeper/Chapter9/DomainModel/EventStore.php @@ -9,8 +9,5 @@ interface EventStore { public function append(EventStream $eventStream): void; public function getEventsFor(string $id): EventStream; - - public function fromVersion(string $id, int $version): EventStream; - public function countEventsFor(string $id): int; } //end-snippet \ No newline at end of file diff --git a/src/Cheeper/Chapter9/Infrastructure/DomainModel/RedisEventStore.php b/src/Cheeper/Chapter9/Infrastructure/DomainModel/RedisEventStore.php index bc7fc3b..ebf4833 100644 --- a/src/Cheeper/Chapter9/Infrastructure/DomainModel/RedisEventStore.php +++ b/src/Cheeper/Chapter9/Infrastructure/DomainModel/RedisEventStore.php @@ -48,12 +48,12 @@ class RedisEventStore implements EventStore public function getEventsFor(string $id): EventStream { - return $this->fromVersion($id, 0); + return $this->fromVersion($id); } - public function fromVersion(string $id, int $version): EventStream + private function fromVersion(string $id, int $version = 0): EventStream { - $serializedEvents = (array) $this->redis->lrange( + $serializedEvents = $this->redis->lrange( 'events:' . $id, $version, -1 @@ -74,10 +74,5 @@ class RedisEventStore implements EventStore return new EventStream($id, $events); } - - public function countEventsFor(string $id): int - { - return (int) $this->redis->llen('events:' . $id); - } } //end-snippet \ No newline at end of file