File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ class SchemaFactory
8787 private $ parameterMiddlewares = [];
8888 /** @var Reader */
8989 private $ doctrineAnnotationReader ;
90+ /** @var string */
91+ private $ annotationCacheDir ;
9092 /** @var AuthenticationServiceInterface|null */
9193 private $ authenticationService ;
9294 /** @var AuthorizationServiceInterface|null */
@@ -204,6 +206,13 @@ public function setDoctrineAnnotationReader(Reader $annotationReader): self
204206 return $ this ;
205207 }
206208
209+ public function setAnnotationCacheDir (string $ cacheDir ): self
210+ {
211+ $ this ->annotationCacheDir = $ cacheDir ;
212+
213+ return $ this ;
214+ }
215+
207216 /**
208217 * Returns a cached Doctrine annotation reader.
209218 * Note: we cannot get the annotation reader service in the container as we are in a compiler pass.
@@ -214,7 +223,12 @@ private function getDoctrineAnnotationReader(): Reader
214223 AnnotationRegistry::registerLoader ('class_exists ' );
215224 $ doctrineAnnotationReader = new DoctrineAnnotationReader ();
216225
217- $ cache = function_exists ('apcu_fetch ' ) ? new ApcuCache () : new PhpFileCache (sys_get_temp_dir () . '/graphqlite. ' . crc32 (__DIR__ ));
226+ if (function_exists ('apcu_enabled ' ) && apcu_enabled ()) {
227+ $ cache = new ApcuCache ();
228+ } else {
229+ $ cacheDir = $ this ->annotationCacheDir ?? sys_get_temp_dir ();
230+ $ cache = new PhpFileCache ($ cacheDir . '/graphqlite. ' . crc32 (__DIR__ ));
231+ }
218232
219233 $ cache ->setNamespace ($ this ->cacheNamespace );
220234
You can’t perform that action at this time.
0 commit comments