···11-<?php
22-33-declare(strict_types=1);
44-55-namespace App\Infrastructure\Persistence\ActorStore;
66-77-use App\Domain\ActorStore\ActorStore;
88-use App\Domain\ActorStore\ActorStoreFactory;
99-use App\Infrastructure\Persistence\Blob\InMemoryBlobRepository;
1010-use App\Infrastructure\Persistence\Blob\InMemoryBlobStore;
1111-use App\Infrastructure\Persistence\Preference\InMemoryAccountPrefRepository;
1212-use App\Infrastructure\Persistence\Record\InMemoryBacklinkRepository;
1313-use App\Infrastructure\Persistence\Record\InMemoryRecordBlobRepository;
1414-use App\Infrastructure\Persistence\Record\InMemoryRecordRepository;
1515-use App\Infrastructure\Persistence\Repo\InMemoryRepoBlockRepository;
1616-use App\Infrastructure\Persistence\Repo\InMemoryRepoRootRepository;
1717-1818-/**
1919- * In-memory implementation of ActorStoreFactory.
2020- *
2121- * Lazily creates and caches a full set of in-memory repositories for each DID.
2222- * Destroying a store wipes all state for that DID (e.g. on account deletion).
2323- */
2424-class InMemoryActorStoreFactory implements ActorStoreFactory
2525-{
2626- /** @var array<string, ActorStore> keyed by DID */
2727- private array $stores = [];
2828-2929- public function get(string $did): ActorStore
3030- {
3131- if (!isset($this->stores[$did])) {
3232- $this->stores[$did] = new ActorStore(
3333- did: $did,
3434- records: new InMemoryRecordRepository(),
3535- recordBlobs: new InMemoryRecordBlobRepository(),
3636- backlinks: new InMemoryBacklinkRepository(),
3737- blobs: new InMemoryBlobRepository(),
3838- blobStore: new InMemoryBlobStore(),
3939- repoBlocks: new InMemoryRepoBlockRepository(),
4040- prefs: new InMemoryAccountPrefRepository(),
4141- repoRoot: new InMemoryRepoRootRepository(),
4242- );
4343- }
4444-4545- return $this->stores[$did];
4646- }
4747-4848- public function destroy(string $did): void
4949- {
5050- unset($this->stores[$did]);
5151- }
5252-}