File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ class SchemaFactory
87
87
private $ parameterMiddlewares = [];
88
88
/** @var Reader */
89
89
private $ doctrineAnnotationReader ;
90
+ /** @var string */
91
+ private $ annotationCacheDir ;
90
92
/** @var AuthenticationServiceInterface|null */
91
93
private $ authenticationService ;
92
94
/** @var AuthorizationServiceInterface|null */
@@ -204,6 +206,13 @@ public function setDoctrineAnnotationReader(Reader $annotationReader): self
204
206
return $ this ;
205
207
}
206
208
209
+ public function setAnnotationCacheDir (string $ cacheDir ): self
210
+ {
211
+ $ this ->annotationCacheDir = $ cacheDir ;
212
+
213
+ return $ this ;
214
+ }
215
+
207
216
/**
208
217
* Returns a cached Doctrine annotation reader.
209
218
* 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
214
223
AnnotationRegistry::registerLoader ('class_exists ' );
215
224
$ doctrineAnnotationReader = new DoctrineAnnotationReader ();
216
225
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
+ }
218
232
219
233
$ cache ->setNamespace ($ this ->cacheNamespace );
220
234
You can’t perform that action at this time.
0 commit comments