In Memory Write Repository¶
in_memory_write_repository
¶
In-memory write-only repository implementation.
Provides a concrete implementation of WriteOnlyRepository backed by a
dictionary for command-side operations in CQRS architectures.
InMemoryWriteRepository
¶
Bases: BaseWriteRepository[TWriteAggregateRoot, TWriteId]
In-memory implementation of WriteOnlyRepository for command operations.
Stores aggregates in a dictionary keyed by their identifier. Designed
for command-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_write_repository.py
__init__(storage: MutableMapping[TWriteId, TWriteAggregateRoot] | None = None) -> None
¶
Initialize the write repository with optional external storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage
|
MutableMapping[TWriteId, TWriteAggregateRoot] | None
|
An optional mutable mapping to use as backing storage. |
None
|