99use Flowpack \DecoupledContentStore \Core \Domain \ValueObject \ContentReleaseIdentifier ;
1010use Flowpack \DecoupledContentStore \Core \Domain \ValueObject \PrunnerJobId ;
1111use Flowpack \DecoupledContentStore \Core \Domain \ValueObject \RedisInstanceIdentifier ;
12+ use Flowpack \DecoupledContentStore \Core \Infrastructure \RedisClientManager ;
1213use Flowpack \DecoupledContentStore \NodeEnumeration \Domain \Repository \RedisEnumerationRepository ;
1314use Flowpack \DecoupledContentStore \NodeRendering \Dto \RenderingStatistics ;
1415use Flowpack \DecoupledContentStore \NodeRendering \Infrastructure \RedisRenderingErrorManager ;
@@ -59,6 +60,12 @@ class BackendUiDataService
5960 */
6061 protected $ redisReleaseSwitchService ;
6162
63+ /**
64+ * @Flow\Inject
65+ * @var RedisClientManager
66+ */
67+ protected $ redisClientManager ;
68+
6269 public function loadBackendOverviewData (RedisInstanceIdentifier $ redisInstanceIdentifier )
6370 {
6471 $ contentReleaseIds = $ this ->redisContentReleaseService ->fetchAllReleaseIds ($ redisInstanceIdentifier );
@@ -83,13 +90,30 @@ public function loadBackendOverviewData(RedisInstanceIdentifier $redisInstanceId
8390 $ lastRendering ->getTotalJobs () > 0 ? round ($ lastRendering ->getRenderedJobs ()
8491 / $ lastRendering ->getTotalJobs () * 100 ) : 100 ,
8592 $ firstRendering ->getRenderedJobs (),
86- $ contentReleaseId ->equals ($ this ->redisReleaseSwitchService ->getCurrentRelease ($ redisInstanceIdentifier ))
93+ $ contentReleaseId ->equals ($ this ->redisReleaseSwitchService ->getCurrentRelease ($ redisInstanceIdentifier )),
94+ $ this ->calculateReleaseSize ($ redisInstanceIdentifier , $ contentReleaseId )
8795 );
8896 }
8997
9098 return $ result ;
9199 }
92100
101+ private function calculateReleaseSize (RedisInstanceIdentifier $ redisInstanceIdentifier , ContentReleaseIdentifier $ contentReleaseIdentifier )
102+ {
103+ $ redis = $ this ->redisClientManager ->getRedis ($ redisInstanceIdentifier );
104+ $ allKeys = $ redis ->keys ('* ' );
105+ $ size = 0 ;
106+
107+ foreach ($ allKeys as $ key ) {
108+ if (str_contains ($ key , $ contentReleaseIdentifier ->getIdentifier ())) {
109+ $ size += $ redis ->rawCommand ('memory ' , 'usage ' , $ key );
110+ }
111+ }
112+
113+ // bytes are returned, convert to megabytes
114+ return round ($ size / 100000 , 2 );
115+ }
116+
93117 public function loadDetailsData (ContentReleaseIdentifier $ contentReleaseIdentifier , RedisInstanceIdentifier $ redisInstanceIdentifier ): ContentReleaseDetails
94118 {
95119 $ contentReleaseMetadata = $ this ->redisContentReleaseService ->fetchMetadataForContentRelease ($ contentReleaseIdentifier , $ redisInstanceIdentifier );
0 commit comments