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

TASK: Content cache adjustments #4636

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
46 changes: 46 additions & 0 deletions Neos.Neos/Classes/Cache/ContentCacheFlusherInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* This file is part of the Neos.Neos package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

declare(strict_types=1);

namespace Neos\Neos\Cache;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\Media\Domain\Model\AssetInterface;

/**
* The interface for services flushing content caches triggered by node changes.
*
* It is called when the projection changes: In this case, it is triggered by
* {@see GraphProjectorCatchUpHookForCacheFlushing} which calls this method..
* This is the relevant case if publishing a workspace
* - where we f.e. need to flush the cache for Live.
* @internal this extension point is experimental
*/
nezaniel marked this conversation as resolved.
Show resolved Hide resolved
interface ContentCacheFlusherInterface
{
/**
* Main entry point to *directly* flush the caches of a given NodeAggregate
*/
public function flushNodeAggregate(
ContentRepository $contentRepository,
ContentStreamId $contentStreamId,
NodeAggregateId $nodeAggregateId
): void;

/**
* Fetches possible usages of the asset and registers nodes that use the asset as changed.
*/
public function registerAssetChange(AssetInterface $asset): void;
}
3 changes: 2 additions & 1 deletion Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Neos\Fusion\Core\Cache\ContentCache;
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Media\Domain\Model\AssetVariantInterface;
use Neos\Neos\Cache\ContentCacheFlusherInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -37,7 +38,7 @@
*
* @Flow\Scope("singleton")
*/
class ContentCacheFlusher
class ContentCacheFlusher implements ContentCacheFlusherInterface
{
/**
* @Flow\Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\EventStore\Model\EventEnvelope;
use Neos\Neos\Cache\ContentCacheFlusherInterface;

/**
* Also contains a pragmatic performance booster for some "batch" operations, where the cache flushing
Expand Down Expand Up @@ -116,7 +117,7 @@ public static function disabled(\Closure $fn): void

public function __construct(
private readonly ContentRepository $contentRepository,
private readonly ContentCacheFlusher $contentCacheFlusher
private readonly ContentCacheFlusherInterface $contentCacheFlusher
) {
}

Expand Down Expand Up @@ -145,6 +146,11 @@ public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $even
$eventInstance->getNodeAggregateId()
);
if ($nodeAggregate) {
$this->scheduleCacheFlushJobForNodeAggregate(
$this->contentRepository,
$nodeAggregate->contentStreamId,
$nodeAggregate->nodeAggregateId
);
Comment on lines +149 to +153
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still this part seems to be a bugfix that we want to preserve?

$parentNodeAggregates = $this->contentRepository->getContentGraph()->findParentNodeAggregates(
$nodeAggregate->contentStreamId,
$nodeAggregate->nodeAggregateId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Projection\CatchUpHookFactoryInterface;
use Neos\Neos\Cache\ContentCacheFlusherInterface;

class GraphProjectorCatchUpHookForCacheFlushingFactory implements CatchUpHookFactoryInterface
{
public function __construct(
private readonly ContentCacheFlusher $contentCacheFlusher
private readonly ContentCacheFlusherInterface $contentCacheFlusher
) {
}

Expand Down
2 changes: 0 additions & 2 deletions Neos.Neos/Classes/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\Neos;

use Neos\EventStore\Model\EventEnvelope;
use Neos\Flow\Cache\CacheManager;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Monitor\FileMonitor;
Expand All @@ -26,7 +25,6 @@
use Neos\Neos\Controller\Backend\ContentController;
use Neos\Neos\Domain\Model\Site;
use Neos\Neos\Domain\Service\SiteService;
use Neos\Neos\FrontendRouting\Projection\DocumentUriPathProjection;
use Neos\Neos\Routing\Cache\RouteCacheFlusher;
use Neos\Neos\Fusion\Cache\ContentCacheFlusher;
use Neos\Fusion\Core\Cache\ContentCache;
Expand Down
3 changes: 3 additions & 0 deletions Neos.Neos/Configuration/Objects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ Neos\Neos\AssetUsage\GlobalAssetUsageService:
arguments:
3:
setting: Neos.Neos.assetUsage.contentRepositories

Neos\Neos\Cache\ContentCacheFlusherInterface:
className: Neos\Neos\Fusion\Cache\ContentCacheFlusher