Skip to content

Commit 4edb0b8

Browse files
committed
Do not cache metadata locally as it can cause too high memory usage during cache warming, just rely on the cache
1 parent 63e131f commit 4edb0b8

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

Mapping/DocumentMetadataCollector.php

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ class DocumentMetadataCollector implements WarmableInterface
2121
*/
2222
const OBJECTS_CACHE_KEY_PREFIX = 'sfes.object_properties_metadata.';
2323

24-
/**
25-
* <document_class_FQN> => DocumentMetadata
26-
*
27-
* @var array
28-
*/
29-
private $metadata = [];
30-
31-
/**
32-
* <object_class_FQN> => [<properties_metadata>]
33-
*
34-
* @var array
35-
*/
36-
private $objectsMetadata = [];
37-
3824
/**
3925
* @var array
4026
*
@@ -129,16 +115,11 @@ public function getDocumentMetadata(string $documentClass): DocumentMetadata
129115
{
130116
$documentClass = $this->documentLocator->resolveClassName($documentClass);
131117

132-
if (isset($this->metadata[$documentClass])) {
133-
return $this->metadata[$documentClass];
134-
}
135-
136118
$cacheKey = self::DOCUMENTS_CACHE_KEY_PREFIX.strtr($documentClass, '\\', '.');
137-
$this->metadata[$documentClass] = $this->cache->get($cacheKey, function (ItemInterface $item) use ($documentClass) {
119+
120+
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($documentClass) {
138121
return $this->fetchDocumentMetadata($documentClass);
139122
}, 0);
140-
141-
return $this->metadata[$documentClass];
142123
}
143124

144125
/**
@@ -155,16 +136,11 @@ public function getObjectPropertiesMetadata(string $objectClass): array
155136
{
156137
$objectClass = $this->documentLocator->resolveClassName($objectClass);
157138

158-
if (isset($this->objectsMetadata[$objectClass])) {
159-
return $this->objectsMetadata[$objectClass];
160-
}
161-
162139
$cacheKey = self::OBJECTS_CACHE_KEY_PREFIX.strtr($objectClass, '\\', '.');
163-
$this->objectsMetadata[$objectClass] = $this->cache->get($cacheKey, function (ItemInterface $item) use ($objectClass) {
140+
141+
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($objectClass) {
164142
return $this->parser->getPropertiesMetadata(new \ReflectionClass($objectClass));
165143
}, 0);
166-
167-
return $this->objectsMetadata[$objectClass];
168144
}
169145

170146
/**

0 commit comments

Comments
 (0)