Skip to content

Commit 7ce1709

Browse files
committed
FEATURE: Store rendertime of documents in metadata
1 parent f3f7110 commit 7ce1709

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Classes/Aspects/CacheUrlMappingAspect.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class CacheUrlMappingAspect
3737
*/
3838
protected $isActive = false;
3939

40+
/**
41+
* @var null | int
42+
*/
43+
protected $renderTimestamp = null;
44+
4045
/**
4146
* @var array
4247
*/
@@ -143,7 +148,8 @@ public function storeRootCacheIdentifier(JoinPointInterface $joinPoint)
143148
$arguments = $this->getCurrentArguments($node);
144149
// TODO: To make parallel rendering possible, we need to make sure that the cache key also includes the currently rendered workspace, as the node might originate from a base workspace (usually live). See `DocumentNodeCacheKey`.
145150
$rootKey = DocumentNodeCacheKey::fromNodeAndArguments($node, $arguments);
146-
$rootCacheValues = DocumentNodeCacheValues::create($rootIdentifier, $url);
151+
$rootCacheValues = DocumentNodeCacheValues::create($rootIdentifier, $url)
152+
->withMetadata('renderTime', (int)(microtime(true) * 1000) - $this->renderTimestamp);
147153
// allow other document metadata generators here
148154
$rootCacheValues = $this->nodeRenderingExtensionManager->runDocumentMetadataGenerators($node, $arguments, $this->controllerContext, $rootCacheValues);
149155
$this->contentCacheFrontend->set($rootKey->redisKeyName(), json_encode($rootCacheValues), $rootTags);
@@ -200,6 +206,7 @@ public function beforeDocumentRendering(ContentReleaseLogger $contentReleaseLogg
200206
{
201207
$this->isActive = true;
202208
$this->contentReleaseLogger = $contentReleaseLogger;
209+
$this->renderTimestamp = (int)(microtime(true) * 1000);
203210
}
204211

205212
public function afterDocumentRendering(): void

0 commit comments

Comments
 (0)