In Memory Read Repository¶
in_memory_read_repository
¶
In-memory read-only repository implementation.
Provides a concrete implementation of ReadOnlyRepository backed by a
dictionary for query-side operations in CQRS architectures.
InMemoryReadRepository
¶
Bases: BaseReadRepository[TReadAggregateRoot, TId]
In-memory implementation of ReadOnlyRepository for query operations.
Stores aggregates in a dictionary keyed by their identifier. Designed
for query-side usage in CQRS architectures.
The storage mapping is injected via the constructor and copied on init
to ensure independence from external mutation.
Source code in src/forging_blocks/infrastructure/repositories/in_memory_read_repository.py
__init__(storage: Mapping[TId, TReadAggregateRoot] | None = None) -> None
¶
Initialize the read repository with optional external storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage
|
Mapping[TId, TReadAggregateRoot] | None
|
An optional mapping to use as backing storage. |
None
|