-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
register CatchUpHook for flushing Subgraph
- Loading branch information
1 parent
c8953e6
commit 66193dd
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...tRepositoryRegistry/Classes/SubgraphCachingInMemory/FlushSubgraphCachePoolCatchUpHook.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepositoryRegistry\SubgraphCachingInMemory; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\ContentRepository\Core\EventStore\EventInterface; | ||
use Neos\ContentRepository\Core\Projection\CatchUpHookInterface; | ||
use Neos\EventStore\Model\EventEnvelope; | ||
|
||
/** | ||
* Ensures that the {@see SubgraphCachePool} is flushed always when content changes. This CatchUpHook | ||
* is triggered when projections change. | ||
* | ||
* @internal | ||
*/ | ||
#[Flow\Proxy(false)] | ||
final class FlushSubgraphCachePoolCatchUpHook implements CatchUpHookInterface | ||
{ | ||
|
||
public function __construct(private readonly SubgraphCachePool $subgraphCachePool) | ||
{ | ||
} | ||
|
||
public function onBeforeCatchUp(): void | ||
{ | ||
} | ||
|
||
public function onBeforeEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope): void | ||
{ | ||
} | ||
|
||
public function onAfterEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope): void | ||
{ | ||
$this->subgraphCachePool->reset(); | ||
} | ||
|
||
public function onBeforeBatchCompleted(): void | ||
{ | ||
} | ||
|
||
public function onAfterCatchUp(): void | ||
{ | ||
$this->subgraphCachePool->reset(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...toryRegistry/Classes/SubgraphCachingInMemory/FlushSubgraphCachePoolCatchUpHookFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepositoryRegistry\SubgraphCachingInMemory; | ||
|
||
use Neos\ContentRepository\Core\ContentRepository; | ||
use Neos\ContentRepository\Core\Projection\CatchUpHookFactoryInterface; | ||
use Neos\ContentRepository\Core\Projection\CatchUpHookInterface; | ||
|
||
/** | ||
* Factory for {@see FlushSubgraphCachePoolCatchUpHook}, auto-registered in Settings.yaml for GraphProjection | ||
* | ||
* @internal | ||
*/ | ||
class FlushSubgraphCachePoolCatchUpHookFactory implements CatchUpHookFactoryInterface | ||
{ | ||
|
||
public function __construct( | ||
private readonly SubgraphCachePool $subgraphCachePool | ||
) { | ||
} | ||
public function build(ContentRepository $contentRepository): CatchUpHookInterface | ||
{ | ||
return new FlushSubgraphCachePoolCatchUpHook($this->subgraphCachePool); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters