@@ 0,0 1,38 @@
+import uuid
+
+import eventsourcing.application
+
+
+class QuickRepo(eventsourcing.application.Repository):
+ """A quicker :class:`~eventsourcing.application.Repository`.
+
+ There is one trade-off to be aware of: the repository should not
+ store "deleted" aggregates.
+
+ Soft-deleted aggregates will still appear in the repository, by
+ definition. There are regular aggregates with a special event to
+ mark them as deleted. Since the aggregates are still stored in the
+ repository, the identifiers of such aggregates will pass the
+ containment test::
+
+ >>> my_agg_id: uuid.UUID
+ >>> app: eventsourcing.application.Application
+ >>> ... # soft delete the aggregate
+ >>> my_agg_id in app.repository
+ True
+ """
+
+ def __contains__(self, item: uuid.UUID) -> bool:
+ """Whether an aggregate exists in the repository.
+
+ The current state of the aggregate is not relevant here, only
+ that there is at least one creation event about the aggregate
+ identifier in the repository.
+ """
+ if self.cache and self.cache.get(item):
+ return True
+ return (
+ self.event_store.recorder.select_events(
+ originator_id=item, gt=1, lte=1, limit=1
+ )
+ ) != []