Skip to content

Commit

Permalink
Only use CachedReader if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Mar 23, 2023
1 parent 55e0a85 commit cb6e085
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Service/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ protected function createDriver(ContainerInterface $container, Driver $options):
)
) {
$reader = new Annotations\AnnotationReader();
$reader = new Annotations\CachedReader(
new Annotations\IndexedReader($reader),
$container->get($options->getCache())
);
// Decorate reader with cache behavior if available:
if (class_exists(Annotations\CachedReader::class)) {
$reader = new Annotations\CachedReader(
new Annotations\IndexedReader($reader),
$container->get($options->getCache())
);
}
$driver = new $class($reader, $paths);
} else {
$driver = new $class($paths);
Expand Down

0 comments on commit cb6e085

Please sign in to comment.