44
55namespace Flowpack \DecoupledContentStore ;
66
7+ use Flowpack \DecoupledContentStore \Core \Infrastructure \RedisClientManager ;
78use Neos \Flow \Annotations as Flow ;
89use Flowpack \Prunner \PrunnerApiService ;
910use Flowpack \Prunner \ValueObject \PipelineName ;
@@ -26,16 +27,29 @@ class ContentReleaseManager
2627 */
2728 protected $ prunnerApiService ;
2829
30+ /**
31+ * @Flow\Inject
32+ * @var RedisClientManager
33+ */
34+ protected $ redisClientManager ;
35+
36+ const REDIS_CURRENT_RELEASE_KEY = 'contentStore:current ' ;
37+ const NO_PREVIOUS_RELEASE = 'NO_PREVIOUS_RELEASE ' ;
2938
3039 public function startIncrementalContentRelease ()
3140 {
32- $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), ['contentReleaseId ' => (string )time ()]);
41+ $ redis = $ this ->redisClientManager ->getPrimaryRedis ();
42+ $ currentContentReleaseId = $ redis ->get (self ::REDIS_CURRENT_RELEASE_KEY );
43+
44+ // the currentContentReleaseId is not used in any pipeline step in this package, but is a common need in other
45+ // use cases in extensions, e.g. calculating the differences between current and new release
46+ $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), ['contentReleaseId ' => (string )time (), 'currentContentReleaseId ' => $ currentContentReleaseId ?: self ::NO_PREVIOUS_RELEASE ]);
3347 }
3448
3549 public function startFullContentRelease ()
3650 {
3751 $ this ->contentCache ->flush ();
38- $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), ['contentReleaseId ' => (string )time ()]);
52+ $ this ->prunnerApiService ->schedulePipeline (PipelineName::create ('do_content_release ' ), ['contentReleaseId ' => (string )time (), ' currentContentReleaseId ' => self :: NO_PREVIOUS_RELEASE ]);
3953 }
4054
4155 public function cancelAllRunningContentReleases ()
@@ -46,4 +60,4 @@ public function cancelAllRunningContentReleases()
4660 $ this ->prunnerApiService ->cancelJob ($ job );
4761 }
4862 }
49- }
63+ }
0 commit comments