Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: extract content subgraph inmemory caching #5244

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Result;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
use Neos\ContentGraph\DoctrineDbalAdapter\NodeQueryBuilder;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
Expand All @@ -29,7 +27,6 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\NodeType\NodeTypeNames;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches\ContentSubgraphWithRuntimeCaches;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindRootNodeAggregatesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
Expand Down Expand Up @@ -67,11 +64,6 @@ final class ContentGraph implements ContentGraphInterface
{
private readonly NodeQueryBuilder $nodeQueryBuilder;

/**
* @var array<string,ContentSubgraphWithRuntimeCaches>
*/
private array $subgraphs = [];

public function __construct(
private readonly Connection $dbal,
private readonly NodeFactory $nodeFactory,
Expand All @@ -98,24 +90,17 @@ public function getSubgraph(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): ContentSubgraphInterface {
$index = $dimensionSpacePoint->hash . '-' . $visibilityConstraints->getHash();
if (!isset($this->subgraphs[$index])) {
$this->subgraphs[$index] = new ContentSubgraphWithRuntimeCaches(
new ContentSubgraph(
$this->contentRepositoryId,
$this->workspaceName,
$this->contentStreamId,
$dimensionSpacePoint,
$visibilityConstraints,
$this->dbal,
$this->nodeFactory,
$this->nodeTypeManager,
$this->tableNames
)
);
}

return $this->subgraphs[$index];
return new ContentSubgraph(
$this->contentRepositoryId,
$this->workspaceName,
$this->contentStreamId,
$dimensionSpacePoint,
$visibilityConstraints,
$this->dbal,
$this->nodeFactory,
$this->nodeTypeManager,
$this->tableNames
);
}

public function findRootNodeAggregateByType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
*/
final class ContentHypergraph implements ContentGraphInterface
{
/**
* @var array|ContentSubhypergraph[]
*/
private array $subhypergraphs;

public function __construct(
private readonly Connection $dbal,
private readonly NodeFactory $nodeFactory,
Expand All @@ -75,22 +70,17 @@ public function getSubgraph(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): ContentSubgraphInterface {
$index = $this->contentStreamId->value . '-' . $dimensionSpacePoint->hash . '-' . $visibilityConstraints->getHash();
if (!isset($this->subhypergraphs[$index])) {
$this->subhypergraphs[$index] = new ContentSubhypergraph(
$this->contentRepositoryId,
$this->contentStreamId,
$this->workspaceName,
$dimensionSpacePoint,
$visibilityConstraints,
$this->dbal,
$this->nodeFactory,
$this->nodeTypeManager,
$this->tableNamePrefix
);
}

return $this->subhypergraphs[$index];
return new ContentSubhypergraph(
$this->contentRepositoryId,
$this->contentStreamId,
$this->workspaceName,
$dimensionSpacePoint,
$visibilityConstraints,
$this->dbal,
$this->nodeFactory,
$this->nodeTypeManager,
$this->tableNamePrefix
);
}

public function findRootNodeAggregateByType(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Neos\ContentRepositoryRegistry;

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface;
use Neos\ContentRepository\Core\Factory\ContentRepositoryFactory;
Expand All @@ -28,6 +27,8 @@
use Neos\ContentRepositoryRegistry\Factory\NodeTypeManager\NodeTypeManagerFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\ProjectionCatchUpTriggerFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\UserIdProvider\UserIdProviderFactoryInterface;
use Neos\ContentRepositoryRegistry\SubgraphCachingInMemory\ContentSubgraphWithRuntimeCaches;
use Neos\ContentRepositoryRegistry\SubgraphCachingInMemory\SubgraphCachePool;
use Neos\EventStore\EventStoreInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
Expand Down Expand Up @@ -55,6 +56,7 @@ final class ContentRepositoryRegistry
public function __construct(
private readonly array $settings,
private readonly ObjectManagerInterface $objectManager,
private readonly SubgraphCachePool $subgraphCachePool,
) {
}

Expand Down Expand Up @@ -104,10 +106,12 @@ public function subgraphForNode(Node $node): ContentSubgraphInterface
{
$contentRepository = $this->get($node->contentRepositoryId);

return $contentRepository->getContentGraph($node->workspaceName)->getSubgraph(
$uncachedSubgraph = $contentRepository->getContentGraph($node->workspaceName)->getSubgraph(
$node->dimensionSpacePoint,
$node->visibilityConstraints
);

return new ContentSubgraphWithRuntimeCaches($uncachedSubgraph, $this->subgraphCachePool);
}

/**
Expand Down
Loading
Loading