From 77f346bed1bd1a9579f08bad556fd4210ad44187 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:02:24 +0200 Subject: [PATCH] Revert "TASK: Reintroduce content graph / cr read model cache" In commit c0ce2baa083290a4de8595fd398b42a7c78632d1 the cache invalidation was partly repaired But as we removed the content graph cache layer currently in 9.0 https://github.com/neos/neos-development-collection/pull/5246 A reintroduction will be discussed as part of another change. Related https://github.com/neos/neos-development-collection/issues/5039 --- Classes/ContentRepositoryReadModel.php | 57 +++----------------------- 1 file changed, 6 insertions(+), 51 deletions(-) diff --git a/Classes/ContentRepositoryReadModel.php b/Classes/ContentRepositoryReadModel.php index c8bb3d6c..95584a07 100644 --- a/Classes/ContentRepositoryReadModel.php +++ b/Classes/ContentRepositoryReadModel.php @@ -16,7 +16,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface; use Neos\ContentRepository\Core\Projection\ProjectionStateInterface; -use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface; use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; @@ -35,48 +34,14 @@ */ final class ContentRepositoryReadModel implements ProjectionStateInterface { - /** - * @var array Runtime cache for {@see ContentGraphInterface} instances, indexed by their workspace name - */ - private array $contentGraphInstancesByWorkspaceName = []; - - /** - * @var array Runtime cache for {@see Workspace} instances, indexed by their name - */ - private array $workspaceInstancesByName = []; - - /** - * @var array Runtime cache for {@see ContentStream} instances, indexed by their name - */ - private array $contentStreamInstancesById = []; - public function __construct( private readonly ContentRepositoryReadModelAdapterInterface $adapter ) { } - /** - * To release all held instances, in case a workspace/content stream relation needs to be reset - * - * @internal Must be invoked by the projection {@see WithMarkStaleInterface::markStale()} to ensure a flush after write operations - */ - public function forgetInstances(): void - { - $this->contentGraphInstancesByWorkspaceName = []; - $this->workspaceInstancesByName = []; - $this->contentStreamInstancesById = []; - } - public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace { - if (!array_key_exists($workspaceName->value, $this->workspaceInstancesByName)) { - $workspace = $this->adapter->findWorkspaceByName($workspaceName); - if ($workspace === null) { - return null; - } - $this->workspaceInstancesByName[$workspaceName->value] = $workspace; - } - return $this->workspaceInstancesByName[$workspaceName->value]; + return $this->adapter->findWorkspaceByName($workspaceName); } public function findWorkspaces(): Workspaces @@ -86,14 +51,7 @@ public function findWorkspaces(): Workspaces public function findContentStreamById(ContentStreamId $contentStreamId): ?ContentStream { - if (!array_key_exists($contentStreamId->value, $this->contentStreamInstancesById)) { - $contentStream = $this->adapter->findContentStreamById($contentStreamId); - if ($contentStream === null) { - return null; - } - $this->contentStreamInstancesById[$contentStreamId->value] = $contentStream; - } - return $this->contentStreamInstancesById[$contentStreamId->value]; + return $this->adapter->findContentStreamById($contentStreamId); } public function findContentStreams(): ContentStreams @@ -119,14 +77,11 @@ public function findUnusedAndRemovedContentStreamIds(): iterable */ public function getContentGraphByWorkspaceName(WorkspaceName $workspaceName): ContentGraphInterface { - if (!array_key_exists($workspaceName->value, $this->contentGraphInstancesByWorkspaceName)) { - $workspace = $this->findWorkspaceByName($workspaceName); - if ($workspace === null) { - throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName); - } - $this->contentGraphInstancesByWorkspaceName[$workspaceName->value] = $this->adapter->buildContentGraph($workspace->workspaceName, $workspace->currentContentStreamId); + $workspace = $this->findWorkspaceByName($workspaceName); + if ($workspace === null) { + throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName); } - return $this->contentGraphInstancesByWorkspaceName[$workspaceName->value]; + return $this->adapter->buildContentGraph($workspace->workspaceName, $workspace->currentContentStreamId); } /**