From 19b95c2dc6bd0caad95f01eb50732b1702a4a71b Mon Sep 17 00:00:00 2001 From: Wilhelm Behncke Date: Fri, 21 Jun 2024 18:51:29 +0200 Subject: [PATCH] BUGFIX: Flush content cache on discard all This is achieved via a catch up hook for the workspace projection that utilized info from the PendingChangesProjection to figure out which nodes need to be considered for cache invalidation. --- ...ceProjectorCatchUpHookForCacheFlushing.php | 64 +++++++++++++++++++ ...ctorCatchUpHookForCacheFlushingFactory.php | 32 ++++++++++ .../Settings.ContentRepositoryRegistry.yaml | 4 ++ 3 files changed, 100 insertions(+) create mode 100644 Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushing.php create mode 100644 Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushingFactory.php diff --git a/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushing.php b/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushing.php new file mode 100644 index 00000000000..00ac11cb9bd --- /dev/null +++ b/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushing.php @@ -0,0 +1,64 @@ +contentRepository->projectionState(ChangeFinder::class); + $changes = $changeFinder->findByContentStreamId($eventInstance->previousContentStreamId); + + foreach ($changes as $change) { + $this->contentCacheFlusher->flushNodeAggregate( + $this->contentRepository, + $eventInstance->workspaceName, + $change->nodeAggregateId + ); + } + } + } + + public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope): void + { + } + + public function onBeforeBatchCompleted(): void + { + } + + public function onAfterCatchUp(): void + { + } +} diff --git a/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushingFactory.php b/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushingFactory.php new file mode 100644 index 00000000000..0060cfe57f9 --- /dev/null +++ b/Neos.Neos/Classes/Fusion/Cache/WorkspaceProjectorCatchUpHookForCacheFlushingFactory.php @@ -0,0 +1,32 @@ +contentCacheFlusher + ); + } +} diff --git a/Neos.Neos/Configuration/Settings.ContentRepositoryRegistry.yaml b/Neos.Neos/Configuration/Settings.ContentRepositoryRegistry.yaml index fe26202594d..68479d6a054 100644 --- a/Neos.Neos/Configuration/Settings.ContentRepositoryRegistry.yaml +++ b/Neos.Neos/Configuration/Settings.ContentRepositoryRegistry.yaml @@ -19,5 +19,9 @@ Neos: catchUpHooks: 'Neos.Neos:FlushContentCache': factoryObjectName: Neos\Neos\Fusion\Cache\GraphProjectorCatchUpHookForCacheFlushingFactory + 'Neos.ContentRepository:Workspace': + catchUpHooks: + 'Neos.Neos:FlushContentCache': + factoryObjectName: Neos\Neos\Fusion\Cache\WorkspaceProjectorCatchUpHookForCacheFlushingFactory 'Neos.Neos:AssetUsage': factoryObjectName: Neos\Neos\AssetUsage\Projection\AssetUsageProjectionFactory