Skip to content

Commit

Permalink
TASK: Reintroduce content graph / cr read model cache
Browse files Browse the repository at this point in the history
With #5246 the cache was naively removed ^^
But with the additional complexity of fetching workspaces etc it makes sense to reintroduce this cache layer.
  • Loading branch information
mhsdesign committed Oct 1, 2024
1 parent 17e39a8 commit 2a781d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
use Neos\ContentRepository\Core\Projection\ProjectionStatus;
use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
Expand All @@ -78,7 +79,7 @@
* @implements ProjectionInterface<ContentRepositoryReadModel>
* @internal but the graph projection is api
*/
final class DoctrineDbalContentGraphProjection implements ProjectionInterface
final class DoctrineDbalContentGraphProjection implements ProjectionInterface, WithMarkStaleInterface
{
use ContentStream;
use NodeMove;
Expand Down Expand Up @@ -168,6 +169,12 @@ public function reset(): void

$this->checkpointStorage->acquireLock();
$this->checkpointStorage->updateAndReleaseLock(SequenceNumber::none());
$this->getState()->forgetInstances();
}

public function markStale(): void
{
$this->getState()->forgetInstances();
}

public function getCheckpointStorage(): DbalCheckpointStorage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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;
Expand Down Expand Up @@ -57,11 +58,10 @@ public function __construct(
/**
* To release all held instances, in case a workspace/content stream relation needs to be reset
*
* @internal Should only be needed after write operations (which should take care on their own)
* @internal Must be invoked by the projection {@see WithMarkStaleInterface::markStale()} to ensure a flush after write operations
*/
public function forgetInstances(): void
{
// todo do we need to reintroduce the cache??? https://github.com/neos/neos-development-collection/pull/5246
$this->contentGraphInstancesByWorkspaceName = [];
$this->workspaceInstancesByName = [];
$this->contentStreamInstancesById = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public function iGetTheNodeAtPath(string $serializedNodePath): void
public function iExpectANodeIdentifiedByXToExistInTheContentGraph(string $serializedNodeDiscriminator): void
{
$nodeDiscriminator = NodeDiscriminator::fromShorthand($serializedNodeDiscriminator);
$contentRepositoryReadModel = $this->currentContentRepository->projectionState(ContentRepositoryReadModel::class);
$contentRepositoryReadModel->forgetInstances();
$matchingWorkspace = $this->currentContentRepository->getWorkspaces()->find(
static fn (Workspace $workspace) => $workspace->currentContentStreamId->equals($nodeDiscriminator->contentStreamId)
);
Expand Down

0 comments on commit 2a781d2

Please sign in to comment.