-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
62 deletions.
There are no files selected for viewing
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
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
60 changes: 60 additions & 0 deletions
60
Neos.ContentRepositoryRegistry/Classes/Service/AsynchronousCatchUpRunnerState.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,60 @@ | ||
<?php | ||
namespace Neos\ContentRepositoryRegistry\Service; | ||
|
||
use Neos\Cache\Frontend\FrontendInterface; | ||
use Neos\ContentRepository\Core\Factory\ContentRepositoryId; | ||
use Neos\ContentRepository\Core\Projection\ProjectionInterface; | ||
|
||
/** | ||
* | ||
*/ | ||
final readonly class AsynchronousCatchUpRunnerState | ||
{ | ||
private string $cacheKeyRunning; | ||
private string $cacheKeyQueued; | ||
|
||
private function __construct( | ||
public ContentRepositoryId $contentRepositoryId, | ||
public string $projectionClassName, | ||
private FrontendInterface $cache | ||
) { | ||
$cacheKeyPrefix = $contentRepositoryId->value . '_' . md5($projectionClassName); | ||
$this->cacheKeyRunning = $cacheKeyPrefix . '_RUNNING'; | ||
$this->cacheKeyQueued = $cacheKeyPrefix . '_QUEUED'; | ||
} | ||
|
||
public static function create(ContentRepositoryId $contentRepositoryId, string $projectionClassName, FrontendInterface $cache): self | ||
{ | ||
return new self($contentRepositoryId, $projectionClassName, $cache); | ||
} | ||
|
||
public function isRunning(): bool | ||
{ | ||
return $this->cache->has($this->cacheKeyRunning); | ||
} | ||
|
||
public function run(): void | ||
{ | ||
$this->cache->set($this->cacheKeyRunning, 1); | ||
} | ||
|
||
public function setStopped(): void | ||
{ | ||
$this->cache->remove($this->cacheKeyRunning); | ||
} | ||
|
||
public function isQueued(): bool | ||
{ | ||
return $this->cache->has($this->cacheKeyQueued); | ||
} | ||
|
||
public function queue(): void | ||
{ | ||
$this->cache->set($this->cacheKeyQueued, 1); | ||
} | ||
|
||
public function dequeue(): void | ||
{ | ||
$this->cache->remove($this->cacheKeyQueued); | ||
} | ||
} |